You have a large image and you want to create a smaller version of that image, the thumbnail. For example, on a web site you might use a thumbnail as a preview to let readers see the basic image before they decide whether to download the larger original.
Use the Image::Magick module from CPAN:
use Image::Magick; $image = Image::Magick->new( ); $image->Read($ORIGINAL_FILENAME); $image->Resize(geometry => '120x90'); $image->Write($THUMBNAIL_FILENAME);
The Image::Magick module is a frontend to the ImageMagick suite, available from http://imagemagick.sourceforge.net. It handles many complex and powerful image manipulations, but here we're only concerned with the very simple resizing.
The Resize method's geometry parameter indicates the new geometry (widthxheight). You can also specify percentages: '75%' to resize each axis proportionally to 3/4 of its original size, or '10%x30%' to resize the X axis to 10% of its original value and the Y axis to 30%.
You can also specify a filter to use and how much to blur or sharpen the image with that filter:
$image->Resize(geometry => '120x90', filter => 'Gaussian', blur => 2);
A blur value greater than 1 indicates blurring; a value less than 1 indicates sharpening. The valid filters are Point, Box, Triangle, Hermite, Hanning, Hamming, Blackman, Gaussian, Quadratic, Cubic, Catrom, Mitchell, Lanczos, Bessel, and Sinc.
The documentation for the Image::Magick modules; Perl Graphics Programming