Grafika\Imagick\Editor::resize PHP Method

resize() public method

Wrapper function for the resizeXXX family of functions. Resize image given width, height and mode.
public resize ( Image &$image, integer $newWidth, integer $newHeight, string $mode = 'fit' ) : Editor
$image Image
$newWidth integer Width in pixels.
$newHeight integer Height in pixels.
$mode string Resize mode. Possible values: "exact", "exactHeight", "exactWidth", "fill", "fit".
return Editor
    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;
    }