Using Perl Image::Magick - extent gravity problem
Posted: 2009-10-18T01:35:19-07:00
I'm resizing a large image to 700x700^ for display on the web which works fine, but then I want to make a thumbnail in a 150x150 geometry centered within a black background. It doesn't seem to be working correctly. Here are my results:
1 - No gravity setting
2 - gravity => 'Center'
3 - gravity => 'East'
4 - gravity => 'West'
Is this a bug, or am I just doing it wrong?
I'm using:
Windows Vista Home Basic
ActivePerl v5.10.1 build 1006
ImageMagick 6.5.7 Q16
1 - No gravity setting
Code: Select all
#!/usr/bin/perl -w
use strict;
use Image::Magick;
my($image);
$image = Image::Magick->new;
$image->Read('fire.jpg');
# make the display image
$image->Resize(geometry => '700x700^');
$image->Write('display.jpg');
# make the thumbnail image
$image->Resize(geometry => '150x150');
$image->Extent(geometry => '150x150', background => 'black');
$image->Write('thumbnail.jpg');
exit;
Code: Select all
...
$image->Extent(gravity => 'Center', geometry => '150x150', background => 'black');
$image->Write('thumbnail_center.jpg');
...
Code: Select all
...
$image->Extent(gravity => 'East', geometry => '150x150', background => 'black');
$image->Write('thumbnail_east.jpg');
...
Code: Select all
...
$image->Extent(gravity => 'West', geometry => '150x150', background => 'black');
$image->Write('thumbnail_west.jpg');
...
I'm using:
Windows Vista Home Basic
ActivePerl v5.10.1 build 1006
ImageMagick 6.5.7 Q16