in reply to GD Module
It puts a 1 pixel black border around the edge. Read doesn't care what the source is, and will write the thumbnail back out in the format that it was read as. The inputs are the name of the source file to be thumbnailed, and the output thumbnail name. Returns the dimensions of the thumbnails.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 p +ictures 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 > $globalPreviewMa +xDimension) { 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); confe +ss "$x" if "$x"; $xSize = $previewX; $ySize = $previewY; } $x = $preview->Border (color=>'black', width=>1, height=>1); confess + "$x" if "$x"; $x = $preview->Set (quality=>90); confess + "$x" if "$x"; $x = $preview->Write ($destination); confess + "$x" if "$x"; return ($xSize, $ySize); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: GD Module
by dvst8 (Initiate) on Jun 20, 2000 at 19:18 UTC | |
by jcwren (Prior) on Jun 20, 2000 at 19:22 UTC | |
by dvst8 (Initiate) on Jun 20, 2000 at 19:24 UTC | |
|
(jcwren) RE: Re: GD Module
by jcwren (Prior) on Jun 21, 2000 at 02:25 UTC |