public function calculateDimensions($width, $height, $maxWidth, $maxHeight)
{
if ($width != $height) {
if ($width > $height) {
$tWidth = $maxWidth;
$tHeight = (($tWidth * $height)/$width);
if ($tHeight > $maxHeight) {
$tHeight = $maxHeight;
$tWidth = (($width * $tHeight)/$height);
}
} else {
$tHeight = $maxHeight;
$tWidth = (($width * $tHeight)/$height);
if ($tWidth > $maxWidth) {
$tWidth = $maxWidth;
$tHeight = (($tWidth * $height)/$width);
}
} } else {
$tWidth = $tHeight = min($maxHeight, $maxWidth);
}
return array('height'=>(int)$tHeight,'width'=>(int)$tWidth);
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結