View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Leo Charre > Image-Magick-Square-1.003 > Image::Magick::Square



Annotate this POD

View/Report Bugs
Module Version: 1.003   Source  


Image::Magick::Square - Takes image and crops trims to a square shape


   use Image::Magick;
        use Image::Magick::Square;      

   # instance and read in image
        my $src = new Image::Magick;

   # square it
        my $square = Image::Magick::Square::create($src);

        # Save it 

   use Image::Magick;
   use Image::Magick::Square;

   my $i = new Image::Magick;


To make a square thumbnail:

        use Image::Magick::Square;
        # Load your source image
        my $src = new Image::Magick;

        # resize it down some..
        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 


The subroutine create() takes as argument an ImageMagick image object.

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.

The subroutine is not exported.

A method is aliased onto Image::Magick::Trim2Square



Argument is Image::Magick object. Trims top and bottom or sides as needed to make it into a square shape. Returns object.


Is an alias for Image::Magick::Square::create(), it is placed inside the Image::Magick namespace.




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 subroutine". This way, you can add more effects, like a shadow, a border, annotate- etc, before you save or display the image.


This basically adds a new method to Image::Magick.

   use Image::Magick;
   use Image::Magick::Square;
   my $i = new Image::Magick;

If you wish to avoid importing Trim2Square onto the Image::Magick namespace..

   use Image::Magick::Square();


perl, Image::Magick, Image::GD::Thumbnail, Image::Magick::Thumbnail, Image::Magick::Thumbnail::Fixed.


Leo Charre leocharre at cpan dot org


Copyright (C) Leo Charre 2006-2008 all rights reserved. Available under the same terms as Perl itself.

syntax highlighting: