From Image::Size to Image::Magick

Posted by: rkassissieh
June232007

I recently moved a site from a shared server that had the Perl library Image::Size installed to one that had Image::Magick. Though Magick has more commands, I had trouble finding a relatively simple function: image size. I wanted to get the image dimensions so that I could create a floating div appropriately sized to an image's dimensions. After many attempts at Googling and experimentation, I finally found the answer in the Get command. I hope you find this tip useful.

use Image::Magick;
$image = Image::Magick->new;
($width, $height) = imgsize("$file");

sub imgsize {
$image->Read(@_[0]);
$height = $image->Get('height');
$width = $image->Get('width');
return ($width,$height);
}

« Prev item - Next item »
-------------------

Comments

No comments yet. You can be the first!

Leave comment




Subscribe comments

Enter email address to subscribe to comment on this item
Click here to manage subscription


buy viagra online
buy levitra