Image::Shoehorn - massage the dimensions and filetype of an image


 use Image::Shoehorn;
 use Data::Dumper;
 my $image = Image::Shoehorn->new({
                                   tmpdir     => "/usr/tmp",
                                   cleanup    => \&my_cleanup
                                  }) || die Image::Shoehorn->last_error();
 my $imgs = $image->import({
                            source     => "/some/large/image.jpg",
                            max_height => 600,
                            valid      => [ "png" ],
                            convert    => 1,
                            scale      => { thumb => "x50", small => "50%" },
                            overwrite  => 1,
                           }) || die Image::Shoehorn->last_error();
 print &Dumper($imgs);


Image::Shoehorn will massage the dimensions and filetype of an image, optionally creating one or more ``scaled'' copies.

It uses Image::Magick to do the heavy lifting and provides a single ``import'' objet method to hide a number of tasks from the user.


Just before I decided to submit this package to the CPAN, I noticed that Lee Goddard had just released Image::Magick::Thumbnail. Although there is a certain amount of overlap, creating thumbnails is only a part of the functionality of Image::Shoehorn.

Image::Shoehorn is designed for taking a single image, optionally converting its file type and resizing it, and then creating one or more ``scaled'' versions of the (modified) image.

One example would be a photo-gallery application where the gallery may define (n) number of scaled versions. In a mod_perl context, if the scaled image had not already been created, the application might create the requested image for the request and then register a cleanup handler to create the remaining ``scaled'' versions. Additionally, scaled images may be defined as ``25%'', ``x50'', ``200x'' or ``25x75'' (Apache::Image::Shoehorn is next...)


This package started life as Image::Import; designed to slurp and munge images into a database. It's not a very exciting name and, further, is a bit ambiguous.

So, I started fishing around for a better name and for a while I was thinking about Image::Tailor - a module for taking in the ``hem'' of an image, of fussing and making an image fit properly.

When I asked the Dict servers for a definition of ``tailor'', it returned a WordNet entry containing the definition...

 make fit for a specific purpose [syn: {shoehorn}]

..and that was that.



Returns the last error recorded by the object.





$pkg = __PACKAGE__->new(\%args)

Object constructor. Valid arguments are :

Returns an object. Woot!



Valid arguments are :

Returns a hash reference with information for the source image -- note that this may or may not be the input document, but the newly converted/resized image created in you tmp directory -- and any scaled images you may have defined.

The keys of the hash are human readable names. The values are hash references whose keys are :

If there was an error, the method will return undef.




$Date: 2003/05/30 22:51:06 $


Aaron Straup Cope



the Image::Magick manpage

the Image::Magick::Thumbnail manpage


Copyright (c) 2001-2003, Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.