Perl+Image::Magick usage: how to assemble several areas in one image into a new image?
I'm new to ImageMagick and haven't figured out how to assemble several areas into a new image. E.g., I know the "geometry" of words "hello" and "world" respectively in an image, what I need to do is to retrieve the word images and put then into one line image while keep their relative positions.
Question1: Suppose I use the perl API, how should I use Composite() or other correct methods to do this?
my $geom = sprintf('%dx%x+%d+%d', $word->{width}, $word->{height}, $offsetx, $offsety);
$x = $lineimg->Composite($wordimg, $geom);
warn "$x" if "$x";
Suppose $lineimg's size is big enough to hold all word images and the geometry has been computed. This code gives out a complain by ImageMagick:
Exception 410: composite image required `Image::Magick' @ Magick.xs/XS_Image__Magick_Mogrify/7790 ...
Question2: currently I only know how to crop a word image out of the original one and then Clone() method to restore the original image. Is there a way to copy instead of crop a specific area from a image? This way can save the time to copy开发者_开发知识库 back and forth the whole image several times.
Does anybody know how to write this kind of processing? I appreciate all your help and suggestions!
-Jin
From the sounds of things Image::Magick is not the right tool for your task. Image::Magick is generally for manipulating entire image - filtering, scaling, converting between formats etc.
Consider the GD module, which can do just about any of the drawing operations you will need.
精彩评论