public function resize($newWidth = null, $newHeight = null)
    {
        if (!is_numeric($newHeight) && !is_numeric($newWidth)) {
            throw new InvalidArgumentException('There are no valid values');
        }

        $height = $this->getHeight();
        $width = $this->getWidth();

        //If the width or height is give as 0, find the correct ratio using the other value
        if (!$newHeight && $newWidth) {
            $newHeight = $height * $newWidth / $width; //Get the new height in the correct ratio
        }

        if ($newHeight && !$newWidth) {
            $newWidth = $width * $newHeight / $height; //Get the new width in the correct ratio
        }


        //Create the image
        $newImage = imagecreatetruecolor($newWidth, $newHeight);
        imagealphablending($newImage, false);
        imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

        $this->image = $newImage;

        return $this;
    }
public function resize($newWidth = null, $newHeight = null)
    {
        if (!is_numeric($newHeight) && !is_numeric($newWidth)) {
            throw new InvalidArgumentException('There are no valid values');
        }

        $height = $this->getHeight();
        $width = $this->getWidth();

        //If the width or height is give as 0, find the correct ratio using the other value
        if (!$newHeight && $newWidth) {
            $newHeight = $height * $newWidth / $width; //Get the new height in the correct ratio
        }

        if ($newHeight && !$newWidth) {
            $newWidth = $width * $newHeight / $height; //Get the new width in the correct ratio
        }


        //Create the image
        $newImage = imagecreatetruecolor($newWidth, $newHeight);
        imagealphablending($newImage, false);
        imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

        $this->image = $newImage;

        return $this;
    }
public function resize ( $ newWidth = null , $ newHeight = null ) { if ( ! is_numeric ( $ newHeight ) && ! is_numeric ( $ newWidth ) ) { throw new InvalidArgumentException ( 'There are no valid values' ) ; } $ height = $ this -> getHeight ( ) ; $ width = $ this -> getWidth ( ) ; //If the width or height is give as 0, find the correct ratio using the other value if ( ! $ newHeight && $ newWidth ) { $ newHeight = $ height * $ newWidth / $ width ; //Get the new height in the correct ratio } if ( $ newHeight && ! $ newWidth ) { $ newWidth = $ width * $ newHeight / $ height ; //Get the new width in the correct ratio } //Create the image $ newImage = imagecreatetruecolor ( $ newWidth , $ newHeight ) ; imagealphablending ( $ newImage , false ) ; imagecopyresampled ( $ newImage , $ this -> image , 0 , 0 , 0 , 0 , $ newWidth , $ newHeight , $ width , $ height ) ; $ this -> image = $ newImage ; return $ this ; }
Resize the image to an new size. Size can be specified in the arugments.

@param int $newWidth The width of the desired image. If 0, the function will automatically calculate the width
using the height ratio.
@param int $newHeight The width of the desired image. If 0, the function will automatically calculate the value
using the width ratio.
@return ImageUtil
Resize the image to an new size . Size can be specified in the arugments .