Hagbone has asked for the wisdom of the Perl Monks concerning the following question:
I am an Image::Magick newbie, and have a question for those who may be familiar with the program/module.
I've searched the monastery to no avail, but did notice that some of the results/comments indicated that the ImageMagick "proper" documentation is, well, lame (and I think I'd have to agree).
I'm trying to produce thumbnails, and the code that follows is working .... my goal is to produce a page of *light weight* on-the-fly thumbnails (that link to the full size image). The full size images are pretty light to start with (800 X 600 pixel gif's that average 25K to 50K). What I've found is (using the code below), if the thumbnails are resized to 1/4 (or less) of the original size, the image weight is always less then the original. If, however, I resize the image to half the original size, the thumbnail weight is often *double* the original.
This makes me think that maybe I'm missing some sort of compression issue in my code, 'cause it sure seems to me that a smaller version of the original should be lighter-weight then the original. Am I missing something, or is the thumbnail idea only appropriate when the reduction is greater then 1/4 the original? (BTW: linux/apache setup)
sub MakeThumb { my $src = Image::Magick->new; $src->Read("$impath/$file"); #grab size my ($width, $height) = $src->Get('width', 'height'); #reduce size $width = $width/$div; $height = $height/$div; # Create the thumbnail based on reduced size my ($thumb,$x,$y) = create($src,$width,$height); # Save thumbnail to file(CH this works) $thumb->Write("$file"); print qq~<img src="$imurl/$file" width="$width" height="$height" b +order="0"><br>~; #get rid of temp file unlink ("$file") or die "can't unlink $file!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Image::Magick - thumbnail compression question
by merlyn (Sage) on Apr 21, 2003 at 23:19 UTC | |
by crenz (Priest) on Apr 22, 2003 at 08:56 UTC | |
|
Re: Image::Magick - thumbnail compression question
by swngnmonk (Pilgrim) on Apr 23, 2003 at 02:56 UTC |