How do you use ImageMagick in Perl?
I'm trying to get the command line equivalent of "identify image.png" to work in Perl.
How do you go about doing this?
Thanks.
Update: I have the following code
开发者_开发知识库 use Image::Magick;
$image = Image::Magick->new;
open(IMAGE, 'image.gif');
$image->Identify(file => \*IMAGE);
close(IMAGE);
But get the following error:
Can't locate Image/Magick.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .)
There is an Identify
method method for PerlMagick as this documentation says.
Its parameters are: file=>file, features=>distance, unique=>{True, False}
So it could be used like this (tested):
use Image::Magick;
$image = Image::Magick->new;
open(IMAGE, 'image.gif');
$image->Read(file => \*IMAGE);
close(IMAGE);
$image->Identify();
If you need only the dimensions:
use Image::Magick;
$image = Image::Magick->new;
my ($width, $height, $size, $format) = $image->Ping('image.gif');
精彩评论