#!/usr/bin/perl
#
# Name: thumb.pl
# Purpose: Demonstrate how to make a thumbnail
#
# Author: Matt Walsh (mr_walsh@yahoo.com)
use strict;
use warnings;
use Image::Magick;
# --------------------------------------------------------------------------------
my($script) = $0;
$script =~ tr|\\|/|;
$script =~ s|.*/||;
print "Script: $script. \n";
print "Image::Magick V $Image::Magick::VERSION. \n";
my($output_file_name) = 'out.jpg';
my($image_name) = 'in.jpg';
my($image) = new Image::Magick();
my($result) = $image -> Read($image_name);
die $result if $result;
my($x_size, $y_size) = $image -> Get('width', 'height');
print "Image: $image_name. Width x Height: $x_size x $y_size. \n";
my(%args) =
(
geometry => '100x100',
);
$result = $image -> Resize(%args);
die $result if $result;
# Purge out profile info - this saves space by getting rid of
# unneeded metadata
$result = $image -> Profile('*');
die $result if $result;
$result = $image -> Write($output_file_name);
die $result if $result;
print "Wrote: $output_file_name. \n";
--
MattWalsh - 01 Feb 2002