Page 1 of 1

Crop 0x0 issue

Posted: 2008-01-04T07:18:44-07:00
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.

Re: Crop 0x0 issue

Posted: 2008-01-04T08:32:12-07:00
by magick
Use $image->Trim() instead of $image->Crop('0x0').

Re: Crop 0x0 issue

Posted: 2008-01-04T08:42:17-07:00
by vaewyn
Thanks much... that did the trick!

Re: Crop 0x0 issue

Posted: 2008-02-05T17:56:13-07:00
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.