static function fit($width, $height, $box, $force = false)
{
if ($width == 0 || $height == 0) {
return array('width' => $box, 'height' => $box);
}
$ratio = self::ratio($width, $height);
if ($width > $height) {
if ($width > $box || $force == true) {
$width = $box;
}
$height = floor($width / $ratio);
} elseif ($height > $width) {
if ($height > $box || $force == true) {
$height = $box;
}
$width = floor($height * $ratio);
} elseif ($width > $box) {
$width = $box;
$height = $box;
}
$output = array();
$output['width'] = $width;
$output['height'] = $height;
return $output;
}