I can't help you really with what you are asking exactly, however, I can show you how I use it, maybe that helps:
[code]
my $original;
# -----------------------------------------------------------------
# hardcode to pass in via cgi in real code
$original = $file;
($val1, $val2) = split(/\./, $original);
my $valtn = $val1. "_th" ;
my $valnrm = $val1. "" ;
my $FNThum = ("$valtn.$val2");
my $FNFull = ("$valnrm.$val2");
my $FileNameIn = $build_photo_path_temp . '/' . $file ;
my $FileNameFull = $build_photo_path . '/' . $FNFull ;
my $FileNameThum = $build_photo_path . '/' . $FNThum ;
# hardcoded paramters to require via config file in real code
my ( $MaxFullimgX , $MaxFullimgY ) = (200,200);
my ( $MaxThumimgX , $MaxThumimgY ) = (75,75);
my $ImageQuality = 80 ; # value 10-90
my $AnnotateFont = '@Comic.ttf' ;
my $AnnotatePointsize = 10 ;
my $AnnotateText = '' ;
# ---------------------------------------------------------
# local var declarations
my $image ;
my ( $imgX , $imgY ) = (0,0);
my ( $ratioX , $ratioY ) = (0.0,0.0);
# -------------------------------- executable ---------------
( $imgX , $imgY ) = $image->Get('columns', 'rows');
# figure out re-sample parameters, keeping aspect ratio for Full-size image
# -----
if ($imgX >= $MaxFullimgX || $imgY >= $MaxFullimgY) {
$ratioX = $MaxFullimgX / $imgX ;
$ratioY = $MaxFullimgY / $imgY ;
if ( $ratioX < $ratioY ) { # use the smaller ratio
( $imgX , $imgY ) = ( $imgX * $ratioX , $imgY * $ratioX ) ;
} else { ( $imgX , $imgY ) = ( $imgX * $ratioY , $imgY * $ratioY ) ;
}
$image->Resize(width=>$imgX , height=>$imgY, blur=>0.5, filter=>Box ); # re-size the image
}
if ( $AnnotateText ) {
$image->Annotate( text=>$AnnotateText ,
font=>$AnnotateFont ,
pointsize=>$AnnotatePointsize );
}
$image->Write( filename=>$FileNameFull , quality=>$ImageQuality );
# figure out re-sample parameters, keeping aspect ratio for thumbnail image
# -----
$ratioX = $MaxThumimgX / $imgX ;
$ratioY = $MaxThumimgY / $imgY ;
if ( $ratioX < $ratioY ) { # use the smaller ratio
( $imgX , $imgY ) = ( $imgX * $ratioX , $imgY * $ratioX ) ;
} else { ( $imgX , $imgY ) = ( $imgX * $ratioY , $imgY * $ratioY ) ;
}
# $image->Sample(width=>$imgX , height=>$imgY );
$image->Resize(width=>$imgX , height=>$imgY, blur=>0.5, filter=>Box ); # re-size the image
$image->Write( filename=>$FileNameThum , quality=>$ImageQuality );
undef $image; # release memory
[/code]
As you can see, I had my uploaded image at:
$build_photo_path_temp
and created a 200 x 200 (max size) and a 75 x 75 image from that with image magick.
Hope this might help.
Lex