Page 1 of 1

crop command not working

Posted: 2016-03-09T11:54:21-07:00
by lulu116
hello , first post here :)
I'm trying to crop a HD picture into a mosaic of overlapping pictures.
if I use convert : convert HD.jpg -crop 6x9+233+233@ tmp.gif it works perfectly
but inside a perl script it fails (ie I got only one picture with bad size)
code :

Code: Select all

$HDIMAGE="HD.jpg";
$hd = Image::Magick->new;
$hd->Read($HDIMAGE);
$crop = $hd->Clone();
$GEOMETRY="6x9+233+233@";
$crop->Crop(geometry=>$GEOMETRY);
$crop->Write('tmp.gif');
thanks for any help.
luc

Re: crop command not working

Posted: 2016-03-09T13:18:38-07:00
by magick
One image is expected since you specified a geometry offset. The resulting image is 6x9 but has a virtual canvas of the original image size. You can remove the virtual canvas with this statement:
  • $crop->Set(page=>'0x0+0+0');

Re: crop command not working

Posted: 2016-03-10T03:18:33-07:00
by lulu116
thanks for your response

what I'm trying to do is something like that :
http://www.imagemagick.org/Usage/crop/#crop_equal
"As a bonus, you can also sub-divide the image so that each tile will 'overlap' its neighbours. You do this by not only using a '@' flag but also specifying the number of pixels of overlap you want."
the output of the convert command is 6*9 = 54 images so I was expecting to have an array of 54 pictures.
maybe it's not feasible in Perl ..