Grafika\Gd\Editor::resizeExactWidth PHP Method

resizeExactWidth() public method

Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width.
public resizeExactWidth ( Image &$image, integer $newWidth ) : Editor
$image Image
$newWidth integer Width in pixels.
return Editor
    public function resizeExactWidth(&$image, $newWidth)
    {
        $width = $image->getWidth();
        $height = $image->getHeight();
        $ratio = $width / $height;
        $resizeWidth = $newWidth;
        $resizeHeight = round($newWidth / $ratio);
        $this->_resize($image, $resizeWidth, $resizeHeight);
        return $this;
    }