Would this work (not a big PHP user):
Syntax: image_scale($img,"200","250")
Example:
<?php
$img = 'images/myfiles/image1.jpg';
echo '<img src="' .$img. '" ' .width_scale($img,"200","250"). '>';
?>
//////////////////////////////////////////////////////////////
// Scale images by width+height //
//////////////////////////////////////////////////////////////
function image_scale($file,$maxwidth,$maxheight) {
list($width,$height) = getimagesize($file);
if (($width > $maxwidth) && ($height > $maxheight)) {
$new_width = $maxwidth;
$new_height = $maxheight;
$dec_perw = $new_width / $width * 100;
$dec_perh = $new_height / $height * 100;
$new_width = $width / 100 * $dec_per;
$new_height = $height / 100 * $dec_per;
return 'width="' .$new_width. '" height="' .$new_height. '"';
}
else {
return 'width="' .$width. '" height="' .$height. '"';
}
}