Perl + Image :: Using magic: how to collect several areas in one image into a new image?

I am new to ImageMagick and have not figured out how to assemble multiple areas into a new image. For example, I know the "geometry" of the words "hello" and "peace" respectively in the image, what I need to do is to extract the images of the words and put them in one image of the line, keeping their relative positions.

Question1: Suppose I use the perl API, how do I use Composite () or other correct methods for this?

my $geom = sprintf('%dx%x+%d+%d', $word->{width}, $word->{height}, $offsetx, $offsety); 
$x = $lineimg->Composite($wordimg, $geom); 
warn "$x" if "$x";

Suppose that the size of $ lineimg is large enough to hold all the text images and the geometry is calculated. This code throws an ImageMagick complaint:

Exception 410: composite image required `Image::Magick' @ Magick.xs/XS_Image__Magick_Mogrify/7790 ...

Question2: I currently know how to crop the word image from the original, and then the Clone () method to restore the original image. Is there a way to copy a specific area from an image instead of a crop? This can save time for copying back and forth the entire image several times.

Does anyone know how to write this kind of processing? I appreciate your help and suggestions!

-Jin

+3
source share
1 answer

Of the sounds of things, Image :: Magick is not the best tool for your task. Image :: Magick, as a rule, is designed to process the entire image - filtering, scaling, conversion between formats, etc.

GD, , .

+1

Source: https://habr.com/ru/post/1734358/


All Articles