Below I've included some code I use often when dealing with images of unknown size. $image holds the name of the image file in this example and it will appropriately resize the photo to be the correct height based on the fixed width you enter for the $width variable.
I used this for a real estate web site (www.gsh.com) to resize the agent photos to a more manageable size. I had some agents uploading photos that were 1600x1200! 😉
<?php
$size = @GetImageSize("<path to photo>/$image");
if ($size[0] == 0) {
echo "No Image Available";
} else {
$width = 120; // Use whatever width you want here
$percent = ($width/$size[0]);
$temp = ($size[1]*$percent);
$newheight = sprintf("%d", $temp);
echo "<img src='$image' width='$width' height='$newheight'>";
}
?>
If you have any questions, feel free to e-mail me.
John Cornett
Senior Development Engineer
Web Teks, Inc.
http://www.web-teks.com
john@web-teks.com