public function resizeFill(&$image, $newWidth, $newHeight)
{
$width = $image->getWidth();
$height = $image->getHeight();
$ratio = $width / $height;
// Base optimum size on new width
$optimumWidth = $newWidth;
$optimumHeight = round($newWidth / $ratio);
if ($optimumWidth < $newWidth or $optimumHeight < $newHeight) {
// Oops, where trying to fill and there are blank areas
// So base optimum size on height instead
$optimumWidth = $newHeight * $ratio;
$optimumHeight = $newHeight;
}
$this->_resize($image, $optimumWidth, $optimumHeight);
$this->crop($image, $newWidth, $newHeight);
// Trim excess parts
return $this;
}