It's a lot easier than you think. Here is a function that I use to display a resized image image in a
predefined popup window to 360 pixels using the builtin php function getimagesize() :
/* Display an image, scale it based on it's size relative to 360 pixels */
function display_image($image_path, $image_name) {
/* Get image parameters (size) for display. */
$image_parm = getimagesize("$image_path/$image_name");
/* If the image height is greater than the image width */
if ($image_parm['0'] > $image_parm['1']) {
/* If the height is greater than 360, scale it */
if ($image_parm['0'] > 360) {
echo "<html>\n<body>\n" .
"\t<img src=\"/images/$image_name\" height=\"270\" width=\"360\" border=\"0\">\n" .
"</body>\n</html>\n";
}
else echo "<html>\n<body>\n" .
"\t<img src=\"/images/$image_name\" $image_parm[3] border=\"0\">\n" .
"</body>\n</html>\n";
}
/* If the image width is greater than the image height */
if ($image_parm['0'] < $image_parm['1']) {
/* If the height is greater than 360, scale it */
if ($image_parm['1'] > 360) {
echo "<html>\n<body>\n" .
"\t<img src=\"/images/$image_name\" height=\"360\" width=\"270\" border=\"0\">\n" .
"</body>\n</html>\n";
}
else echo "<html>\n<body>\n" .
"\t<img src=\"/images/$image_name\" $image_parm[3] border=\"0\">\n" .
"</body>\n</html>\n";
}
}