public static
correctSizeWithRate
(mixed $width, mixed $height, mixed $corWidth = 100, mixed $corHeight = 100)
public static function correctSizeWithRate($width, $height, $corWidth = 100, $corHeight = 100)
{
$image['width'] = $corWidth;
$image['height'] = $corHeight;
if ($width > $height) {
if ($width > $corWidth) {
$image['width'] = $corWidth;
$rate = $width / $corWidth;
$image['height'] = $height / $rate;
} else {
$image['width'] = $width;
$image['height'] = $height;
}
} else {
if ($height > $corHeight) {
$image['height'] = $corHeight;
$rate = $height / $corHeight;
$image['width'] = $width / $rate;
} else {
$image['width'] = $width;
$image['height'] = $height;
}
}
return $image;
}