Image::Magick::Thumbnail::Fixed - Perl extension for creating fixed sized thumbnails without distortion.


SYNOPSIS

  use Image::Magick::Thumbnail::Fixed;
  my $t = new Image::Magick::Thumbnail::Fixed;
  
  # Required parameters
  $t->thumbnail( input   => 'input.jpg',
                 output  => 'output.jpg',
                 width   => 96,
                 height  => 72 );
   
  # Required and optional parameters
  $t->thumbnail( input   => 'input.jpg',
                 output  => 'output.jpg',
                 width   => 96,
                 height  => 72,
                 density => '96x72',
                 gravity => 'center',
                 compose => 'over',
                 quality => '90',
                 bgcolor => 'white',
                 format  => 'jpg' );


DESCRIPTION

Create fixed sized thumbnails without distorting or stretching the source image.

Example: The source image is 349 x 324 (1.077 ratio). The thumbnail image is to be 96x72 (1.333 ratio). Resizing the source image to 96 x 72 will cause distortion. This module will first resize the source in memory (to 66 x 71) and then compose it ontop of the thumbnail canvas.


PREREQUISITES

Image::Magick

REQUIRED PARAMETERS

input
The input path of the source image.

output
The output path of the thumbnail image.

width
The width of the thumbnail image.

height
The height of the thumbnail image.

OPTIONAL PARAMETERS

See http://imagemagick.org/www/perl.html for information regarding optional parameters (density, gravity, compose, color, quality, format).

density
Vertical and horizontal resolution in pixels of the image. Takes an ImageMagick 'geometry' string (ie: '96x72'). Default: width x height of the thumbnail.

gravity
Type of image gravity. Options: {Forget, NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast} Default: center

compose
Composite operator. Options: {Over, In, Out, Atop, Xor, Plus, Minus, Add, Subtract, Difference, Bumpmap, Copy, Mask, Dissolve, Clear, Displace} Default: over

bgcolor
Background color of the thumbnail canvas (will only show if the ratio of the source does not match the ratio of the thumbnail). Options: http://imagemagick.org/www/color.html Default: white

quality
JPEG/MIFF/PNG compression level (range 0-100). Default: 70

format
Image format. Default: jpg

EXPORT

None by default.


VERSION HISTORY

Version 0.01 (18 August 2004): Initial Revision

Version 0.02 (31 August 2004): Perl 5.6.1 support, fixed height/width calculations that were broken in certain situations.

Version 0.03 (25 September 2004): made debug mode more verbose. Caught additional errors.

Version 0.04 (26 April 2005): Fixed debugging conditional that was too loud - pd <paul@dowling.id.au>, fixed bug with square images - Phillip Munt <phil@savvyshopper.net.au>.


=head1 SEE ALSO

the Image::Magick manpage, the Image::Magick::Thumbnail manpage, the Image::Thumbnail manpage


AUTHOR

Adam Roth, <aroth@cpan.org>


COPYRIGHT AND LICENSE

Copyright 2004 by Adam Roth, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Image::Magick::Thumbnail::Fixed - Perl extension for creating fixed sized thumbnails without distortion.