public function resize(&$image, $newWidth, $newHeight, $mode = 'fit')
{
/*
* Resize formula:
* ratio = w / h
* h = w / ratio
* w = h * ratio
*/
switch ($mode) {
case 'exact':
$this->resizeExact($image, $newWidth, $newHeight);
break;
case 'fill':
$this->resizeFill($image, $newWidth, $newHeight);
break;
case 'exactWidth':
$this->resizeExactWidth($image, $newWidth);
break;
case 'exactHeight':
$this->resizeExactHeight($image, $newHeight);
break;
case 'fit':
$this->resizeFit($image, $newWidth, $newHeight);
break;
default:
throw new \Exception(sprintf('Invalid resize mode "%s".', $mode));
}
return $this;
}