views:

153

answers:

0

Hi Everybody,

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