
WilliamC
stranger
Nov 16, 2001, 11:50 PM
Post #4 of 7
(4076 views)
|
There are actualy a great number of ways to do what you want. Heres 2. ### Method 1 using pnmscale,cjpeg,djpeg (common on most linux systems) my $cjpeg="/usr/bin/cjpeg"; my $djpeg="/usr/bin/djpeg"; my $pnmscale="/usr/bin/pnmscale"; my $width=100; # thumbnail width my $height=100; # " height my $scale="1/4"; # scale for djpeg... speeds it up a tad. # if thumbnails from smaller images look strange, # you might try setting this down to 1/2. $infile="/home/pics/pic1.jpg"; $outfile="/home/pics/thumbs/pic1.jpg"; #obviously make sure the thumbs directory exists.... my $pixels=$width * $height; my $command="$djpeg -fast -scale $scale $infile | $pnmscale -pixels $pixels | $cjpeg -dct fast > $outfile"; system($command); ################################################ ### Method 2 using Image::Magick $infile="/home/pics/pic1.jpg"; $outfile="/home/pics/thumbs/pic1.jpg"; #obviously make sure the thumbs directory exists.... $convert = "convert"; $thumbnail_size = "75"; # largest width or height of thumbnail $convert="$convert -geometry ${thumbnail_size}x${thumbnail_size}+0+0"; system("$convert $infile $outfile"); PerlCoders CGI Supersite http://www.perlcoders.com
|