public \Joomla\CMS\Image\Image
cropResize
(mixed $width, mixed $height, mixed $createNew = true)
/**
* Method to crop an image after resizing it to maintain
* proportions without having to do all the set up work.
*
* @param integer $width The desired width of the image in pixels or a percentage.
* @param integer $height The desired height of the image in pixels or a percentage.
* @param boolean $createNew If true the current image will be cloned, resized, cropped and returned.
*
* @return Image
*
* @since 2.5.0
*/
public function cropResize($width, $height, $createNew = true)
{
$width = $this->sanitizeWidth($width, $height);
$height = $this->sanitizeHeight($height, $width);
$resizewidth = $width;
$resizeheight = $height;
if ($this->getWidth() / $width < $this->getHeight() / $height) {
$resizeheight = 0;
} else {
$resizewidth = 0;
}
return $this->resize($resizewidth, $resizeheight, $createNew)->crop($width, $height, null, null, false);
}