No repage in PerlMagick Crop()?

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

No repage in PerlMagick Crop()?

Post by rmabry »

Is it possible that there is no repage available in PerlMagick's Crop()?

I do not see a repage operator in the PerlMagick doc, so I tried forcing the issue using the geometry string (!) á la the command line.

Code: Select all

use Image::Magick;

$image1 = new Image::Magick;

$image1->Read('logo:');
$image2 = $image1->Clone();

$image1->Crop("300x200+50+75");
$image1->Write(filename=>'logocrop1.png');

$image2->Crop("300x200+50+75!");
$image2->Write(filename=>'logocrop2.png');
Executing the above gives two files. But identify shows the trouble - the second file is not +repaged:

Code: Select all

> identify logocrop1.png

logocrop1.png PNG 300x200 640x480+50+75 DirectClass 16-bit  31.3926kb

> identify logocrop2.png

logocrop2.png PNG 300x200 640x480+50+75 DirectClass 16-bit 31.3926kb
The command line versions, of course, are fine:

Code: Select all

> convert logo: -crop 300x200+50+75 logocrop1.png

> convert logo: -crop 300x200+50+75! logocrop2.png

>identify logocrop1.png

logocrop1.png PNG 300x200 640x480+50+75 DirectClass 16-bit 31.3926kb

>identify logocrop2.png

logocrop2.png PNG 300x200 300x200+0+0 DirectClass 16-bit 31.373kb
So how do I (or can I) force a repage in PerlMagick?

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

  • $image->Set( page=>'0x0+0+0' );
is equivalent to the +repage command-line option.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote:
  • $image->Set( page=>'0x0+0+0' );
is equivalent to the +repage command-line option.


Fabulous, Mr. Wizard!

I appreciate your speedy replies but worry that you never sleep.

Rick
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote:
  • $image->Set( page=>'0x0+0+0' );
is equivalent to the +repage command-line option.


Now I'm just curious - shouldn't / couldn't the commandline-style geometry work with Crop(), if for no other reason than to make code a bit more compact (and maybe faster)? Or perhaps another option to Crop() to force a repage? I'll probably be calling Set( page=>'0x0+0+0' ) after every crop, which is fine but seems excessive. Of course I can write a sub, but still...

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Operations are typically more atomic with an API than on the command-line. The burden is on the programmer. In the case of PerlMagick, since its object oriented, you could always write a class to support crop with repage.
Post Reply