public function resizeFill(&$image, $newWidth, $newHeight)
    {
        $width  = $image->getWidth();
        $height = $image->getHeight();
        $ratio  = $width / $height;

        // Base optimum size on new width
        $optimumWidth  = $newWidth;
        $optimumHeight = round($newWidth / $ratio);

        if (($optimumWidth < $newWidth) or ($optimumHeight < $newHeight)) { // Oops, where trying to fill and there are blank areas
            // So base optimum size on height instead
            $optimumWidth  = $newHeight * $ratio;
            $optimumHeight = $newHeight;
        }

        $this->_resize($image, $optimumWidth, $optimumHeight);
        $this->crop($image, $newWidth, $newHeight); // Trim excess parts

        return $this;
    }
public function resizeFill(&$image, $newWidth, $newHeight)
    {
        $width  = $image->getWidth();
        $height = $image->getHeight();
        $ratio  = $width / $height;

        // Base optimum size on new width
        $optimumWidth  = $newWidth;
        $optimumHeight = round($newWidth / $ratio);

        if (($optimumWidth < $newWidth) or ($optimumHeight < $newHeight)) { // Oops, where trying to fill and there are blank areas
            // So base optimum size on height instead
            $optimumWidth  = $newHeight * $ratio;
            $optimumHeight = $newHeight;
        }

        $this->_resize($image, $optimumWidth, $optimumHeight);
        $this->crop($image, $newWidth, $newHeight); // Trim excess parts

        return $this;
    }
public function resizeFill ( & $ image , $ newWidth , $ newHeight ) { $ width = $ image -> getWidth ( ) ; $ height = $ image -> getHeight ( ) ; $ ratio = $ width / $ height ; // Base optimum size on new width $ optimumWidth = $ newWidth ; $ optimumHeight = round ( $ newWidth / $ ratio ) ; if ( ( $ optimumWidth < $ newWidth ) or ( $ optimumHeight < $ newHeight ) ) { // Oops, where trying to fill and there are blank areas // So base optimum size on height instead $ optimumWidth = $ newHeight * $ ratio ; $ optimumHeight = $ newHeight ; } $ this -> _resize ( $ image , $ optimumWidth , $ optimumHeight ) ; $ this -> crop ( $ image , $ newWidth , $ newHeight ) ; // Trim excess parts return $ this ; }
Resize image to fill all the space in the given dimension. Excess parts are cropped.

@param Image $image
@param int $newWidth Width in pixels.
@param int $newHeight Height in pixels.

@return self
Resize image to fill all the space in the given dimension . Excess parts are cropped .