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>); }
In reply to Can't automaticaly HTML-resize my images by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |