Forgive me for being a dumb Perl newbie...
I've gone through your code, and it all makes sense except for the confess stuff... what does that mean?
I'm using PerlScript in an ASP page, and tried out your sub... here is what my page looks like:
<code>
<%@ LANGUAGE = PerlScript
my $globalPreviewMaxDimension = 100;
sub util_photo_GenerateThumbnail
{
my ($source, $destination) = @_;
my $preview = Image::Magick->new;
my $x = $preview->Read ($source); confess "$x" if "$x";
my ($xSize, $ySize) = $preview->Get ('width', 'height'); # Get the pictures dimensions
#
# Calculate dimensions of thumbnail
#
my $scaleFactor;
my $previewX;
my $previewY;
#
# Only scale if either axis is larger than the preview size
#
if ($xSize > $globalPreviewMaxDimension || $ySize > $globalPreviewMaxDimension)
{
if ($xSize > $ySize)
{
$scaleFactor = $globalPreviewMaxDimension / $xSize;
$previewX = $globalPreviewMaxDimension;
$previewY = int ($ySize * $scaleFactor);
}
else
{
$scaleFactor = $globalPreviewMaxDimension / $ySize;
$previewY = $globalPreviewMaxDimension;
$previewX = int ($xSize * $scaleFactor);
}
$x = $preview->Scale (width=>$previewX, height=>$previewY); confess "$x" if "$x";
$xSize = $previewX;
$ySize = $previewY;
}
%