Oh wise ones ....

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"; }

In reply to Image::Magick - thumbnail compression question by Hagbone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.