I am sugest to you keep width and height in same dimension. Otherwise you will get disproportional resizing for higher images.
PHP Code:
$maxWidth_Height = 350;
$sizes = getimagesize($uploadedfile);
// resize if is width bigger or same like height
if ($sizes[0] >= $sizes[1] && $sizes[0] > $maxWidth_Height) {
$resize = $sizes[0]/$maxWidth_Height;
$width = round($sizes[0]/$resize);
$height = round($sizes[1]/$resize);
// resize if is height bigger then width
} elseif($sizes[0] < $sizes[1] && $sizes[1] > $maxWidth_Height) {
$resize = $sizes[1]/$maxWidth_Height;
$height = round($sizes[1]/$resize);
$width = round($sizes[0]/$resize);
// don't resize if both dimension are smaller then $maxWidth_Height
} else {
$width = $sizes[0];
$height = $sizes[1];
}
I am using this script long time like part of my image gallery without any error.
Shivaji
__________________
Please login or register to view this content. Registration is FREE - uncommon free scripts
Please login or register to view this content. Registration is FREE - Städte, Sport, Party, Gourment, Apartments, Hotels
|