identify different for command line versus perl conversion

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
trwww
Posts: 4
Joined: 2015-08-14T21:33:24-07:00
Authentication code: 1151

identify different for command line versus perl conversion

Post by trwww » 2015-08-21T23:54:02-07:00

I (think I) have successfully rewritten the following convert command with the perl below that. The images appear to be the same when compared in a viewer, but the identify command gives slightly different output between the two. The command line:

Code: Select all

convert in.jpg -resize 250x250^ -gravity center -crop 250x250+0+0 +repage -quality 100 out.png
And the perl:

Code: Select all

my $image = Image::Magick->new;
$image->Read( $file );

$image->Set(quality =>   100    );
$image->Set(page    =>'0x0+0+0' );

$image->Resize( geometry => sprintf '%dx%d^', $width, $height );
$image->Crop( gravity => 'Center', geometry => sprintf '%dx%d+0+0', $width, $height );

$image->Write('out.png');
The identify output for each:

Code: Select all

out.cmd.png PNG 250x250 250x250+0+0 8-bit sRGB 107KB 0.000u 0:00.000
out.perl.png PNG 250x250 370x250+60+0 8-bit sRGB 107KB 0.000u 0:00.000
As you can see the identify output for the perl conversion is slightly different than the desired command line conversion. Even though they appear to render the same in a image viewer.

Is this "good enough" for web images? Any advice for what needs to change in the perl program to get the perl output to identify the same as the command line output?

trwww
Posts: 4
Joined: 2015-08-14T21:33:24-07:00
Authentication code: 1151

Re: identify different for command line versus perl conversion

Post by trwww » 2015-08-22T00:06:15-07:00

Gah, I see, you have to set the page after the crop.

Post Reply