public static
correctSizeWithRate
(mixed $width, mixed $height, mixed $corWidth = 100, mixed $corHeight = 100, mixed $diffThumbHeight = 0)
/*
* Used for external images: Picasa, Facebook
*/
public static function correctSizeWithRate($width, $height, $corWidth = 100, $corHeight = 100, $diffThumbHeight = 0)
{
$image['width'] = $corWidth;
$image['height'] = $corHeight;
if ((int) $diffThumbHeight > 0) {
$ratio = $width / $height;
$image['height'] = $ratio * $image['height'];
return $image;
}
// Don't do anything with images:
if ($width < $corWidth && $height < $corHeight) {
$image['width'] = $width;
$image['height'] = $height;
} else {
if ($width > $height) {
if ($width > $corWidth) {
$image['width'] = $corWidth;
$rate = (int) $width / (int) $corWidth;
$image['height'] = (int) $height / $rate;
} else {
$image['width'] = $width;
$image['height'] = $height;
}
} else {
if ($height > $corHeight) {
$image['height'] = $corHeight;
$rate = (int) $height / (int) $corHeight;
$image['width'] = (int) $width / $rate;
} else {
$image['width'] = $width;
$image['height'] = $height;
}
}
}
return $image;
}