Jarves\Filesystem\Filesystem::getResizeMax PHP Method

getResizeMax() public method

Resize a image and returns it's object.
public getResizeMax ( string $path, integer $width, integer $height ) : PHPImageWorkshop\Core\ImageWorkshopLayer
$path string
$width integer
$height integer
return PHPImageWorkshop\Core\ImageWorkshopLayer
    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;
    }