function getLimitSize($w_max, $h_max, $w, $h) {
if ($w_max*$h_max*$w*$h == 0) {
return false;
}
if ($h/$w < $h_max/$w_max) {
$w_new = $w_max;
$h_new = $h/$w * $w_new;
} else {
$h_new = $h_max;
$w_new = $w/$h * $h_new;
}
return array(round($w_new), round($h_new));
}
Leave a Comment