public function getResizeMax($path, $width, $height)
{
$content = $this->read($path);
if (!$content) {
return null;
}
$image = \PHPImageWorkshop\ImageWorkshop::initFromString($content);
$widthOriginal = $image->getWidth();
$heightOriginal = $image->getHeight();
if ($width > $widthOriginal && $height > $heightOriginal) {
return $image;
}
$newWidth = null;
$newHeight = null;
if ($widthOriginal > $heightOriginal) {
$newWidth = $width;
} else {
$newHeight = $height;
}
$image->resizeInPixel($newWidth, $newHeight, true);
if ($image->getHeight() > $height) {
$image->resizeInPixel(null, $height, true);
}
if ($image->getWidth() > $width) {
$image->resizeInPixel($width, null, true);
}
return $image;
}