$width = 300;
$height = 500;
$scale = 16/9;$newWidth и $newHeight такие, чтобы соответствовали условиям$newWidth / $newHeight == $scale &&
$newWidth >= $width &&
$newHeight >= $height. Объясните на словах или формульно как это насчитать?
$width = 300;
$height = 500;
$scale = 16/9;
$newWidth = 0;
$newHeight = 0;
if ($width / $height > $scale) {
$newWidth = $width;
$newHeight = round($width / $scale);
} else {
$newHeight = $height;
$newWidth = round($height * $scale);
}
echo($newWidth.'x'.$newHeight);