Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to make sure my images are less than max_h and max_w, if they are I want them both resized so they're the same aspect ratio but under my requirements.
I tried the below and I'm guessing my problem lies in it only checks one side, not both. So if BOTH sides are too big, only one is resized leaving the other one POSSIBLY too big.
Can someone help me?
############################## # Image Resize ############################## use Image::Info qw(image_info dim); my $img_info = image_info("pictures/$pic_id.jpg"); my ($height, $width) = dim($img_info); my ($max_width, $max_height ) = (600,800); if ($height >= $max_height) { print qq(<center><a href="http://www.site.com/viewer2.cgi?id=$pic_i +d" target="new"><img src="$img_src" height="800" border="0"></href></ +center>); } elsif ($width >= $max_width) { print qq(<center><a href="http://www.site.com/viewer2.cgi?id=$pic_i +d" target="new"><img src="$img_src" width="600" border="0"></a></cent +er>); } else { print qq(<center><a href="http://www.site.com/viewer2.cgi?id=$pic_i +d" target="new"><img src="$img_src" border="0"></a></center>); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't automaticaly HTML-resize my images
by grep (Monsignor) on Jul 20, 2007 at 02:19 UTC | |
by Anonymous Monk on Jul 20, 2007 at 02:57 UTC | |
by almut (Canon) on Jul 20, 2007 at 04:03 UTC | |
by marto (Cardinal) on Jul 20, 2007 at 08:13 UTC | |
|
Re: Can't automaticaly HTML-resize my images
by GrandFather (Saint) on Jul 20, 2007 at 01:56 UTC | |
by Anonymous Monk on Jul 20, 2007 at 02:14 UTC |