Crop 0x0 issue

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
vaewyn

Crop 0x0 issue

Post by vaewyn »

I just changed from 6.0.3 to 6.2.9 and Crop(geometry=>'0x0') fails to crop the image at all. It use to crop the image down to the smallest size possible only chopping the background color areas. Now it seems to do nothing. Is/was that a known issue with this version? I would love to upgrade it to test a newer one but am restricted from doing that in our environment. As a side note the command line convert still works.

Thanks for any help you could give.

Here is an example of me trying to use it:

use Image::Magick;
my $image = new Image::Magick;
$image->Set('size' => "320x240");

my $x = $image->Read('xc:white');
warn $x if $x;

$image->Set('pixel[10,10]'=>'red');
$image->Set('pixel[49,49]'=>'red');

$x = $image->Crop(geometry=>'0x0');
warn $x if $x;

$image->Display();


This use to produce a 39x39 image with 2 corner pixels red... now I get a 320x240 with 2 red dots in a field of white.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Crop 0x0 issue

Post by magick »

Use $image->Trim() instead of $image->Crop('0x0').
vaewyn

Re: Crop 0x0 issue

Post by vaewyn »

Thanks much... that did the trick!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Crop 0x0 issue

Post by anthony »

As a historical note -crop 0x0 was the old 'trim' method (generally IM v5 and before).

However As IM examples reviewed and documented (by example) the -crop function, it was found that a 'zero' dimension was the best way to represent the images canvas size when cropping. That is to allow cropping of rows or columns from an image.
See IM examples Strip Cropping...
http://imagemagick.org/Usage/crop/#crop_strip

Because of this a -crop 0x0 was nolonger usable as meaning -trim, so a new, more specific operator was added for this purpose.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply