View on
MetaCPAN
Aaron Straup Cope > Image-Shoehorn-1.42 > Image::Shoehorn

Download:
Image-Shoehorn-1.42.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.42   Source  

NAME ^

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

SYNOPSIS ^

 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);

DESCRIPTION ^

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.

RATIONALE ^

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...)

SHOEHORN ?! ^

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.

PACKAGE METHODS ^

__PACKAGE__->last_error()

Returns the last error recorded by the object.

__PACKAGE__->dimensions_for_scale($x,$y,$scale)

__PACKAGE__->scaled_name([$source,$scale])

__PACKAGE__->converted_name([$source,$type])

__PACKAGE__->scaled_dimensions([$cur_x,$cur_y,$new_x,$new_y])

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

Object constructor. Valid arguments are :

Returns an object. Woot!

OBJECT METHODS ^

$obj->import(\%args)

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.

VERSION ^

1.42

DATE ^

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

AUTHOR ^

Aaron Straup Cope

TO DO ^

SEE ALSO ^

Image::Magick

Image::Magick::Thumbnail

LICENSE ^

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.

syntax highlighting: