Image::Magick::Square - Takes image and crops to a square
use Image::Magick::Square; # Load your source image my $src = new Image::Magick; $src->Read('source.jpg'); # crop to square image my $square_thumb = Image::Magick::Square::create($thumb); # Save it $square_thumb->Write('square.jpg');
To make a square thumbnail:
use Image::Magick::Square; # Load your source image my $src = new Image::Magick; $src->Read('source.jpg'); # make into a thumbnail my ($thumb,$x,$y) = Image::Magick::Thumbnail::create($src,50); # crop to biggest square that will fit inside image. my ($square_thumb,$side) = Image::Magick::Square::create($thumb); # Save it $square_thumb->Write('square_thumb.jpg');
The subroutine create takes as argument an ImageMagick image object.
create
It returns an ImageMagick image object (the thumbnail), as well as the number of pixels of the side of the image.
It does not take dimension arguments, because if your image is cropped according to the dimensions it already posseses.
This module is useful if you want to make square thumbnails. You should first make the thumbnail, and then call create, so as to use less of the computer's resources.
You can run this conversion on any image magick object.
Image::Magick
Yes, Image::Magick::Thumbnail::Fixed will make a fixed size thumbnail. It's great, I love it. Except for one thing, it does not take an existing Image::Magick object to work on. It does too much. It doesn't return an image object either.
Image::Magick::Square is more a specialized crop then a "thumbnail routine". This way, you can add more effects, like a shadow, a border, annotate- etc, before you save or display the image.
None by default.
perl, Image::Magick, Image::GD::Thumbnail, Image::Magick::Thumbnail, Image::Magick::Thumbnail::Fixed.
Leo Charre, <leo@leocharre.com>
Copyright (C) Leo Charre 2006 all rights reserved. Available under the same terms as Perl itself.
To install Image::Magick::Square, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::Magick::Square
CPAN shell
perl -MCPAN -e shell install Image::Magick::Square
For more information on module installation, please visit the detailed CPAN module installation guide.