Forum Moderators: coopster
Its the GetImagesize php function. Have a read through, and see if it helps. ;)
wruk999
it will return an array with keys, 'width' and 'height' that you can use to set the size of your image in html.
function ResizeImage($imageNamePath, $maxSize = 150) {
$size = getimagesize($imageNamePath);
$new_width = $size[0];
$new_height = $size[1];
if ($size[0] > $maxSize) {
$new_width = $maxSize;
$multiplier = $size[0] / $maxSize;
$new_height = $size[1] / $multiplier;
} elseif ($size[1] > $maxSize) {
$new_height = $maxSize;
$multiplier = $size[1] / $maxSize;
$new_width = $size[0] / $multiplier;
}
$imageSize['width'] = $new_width;
$imageSize['height'] = $new_height;return $imageSize;
}
$sizeAry = ResizeImage("picture.jpg", 200);
echo "<img src=\"picture.jpg\" width=\"" . $sizeAry['width'] . "\" height=\"" . $sizeAry['height'] . "\">";
i'd suggest that you store the filesize of the image after it's chosn, you can then check the filesize hasn't changed... if changed then check again, as filessize won't need you to transfer the whole image every time to your server.