public function scale($width = null, $height = null)
    {
        //get the source width and height
        $orgWidth = imagesx($this->resource);
        $orgHeight = imagesy($this->resource);

        //set the width if none is defined
        if (is_null($width)) {
            $width = $orgWidth;
        }

        //set the height if none is defined
        if (is_null($height)) {
            $height = $orgHeight;
        }

        //if the width and height are the same as the originals
        if ($width == $orgWidth && $height == $orgHeight) {
            //there's no need to process
            return $this;
        }

        //if we are here then we do need to crop
        //create the new resource with the width and height
        $scale = imagecreatetruecolor($width, $height);

        //render the image
        imagecopyresampled($scale, $this->resource, 0, 0, 0, 0, $width, $height, $orgWidth, $orgHeight);

        //destroy the original resource
        imagedestroy($this->resource);

        //assign the new resource
        $this->resource = $scale;

        return $this;
    }
public function scale($width = null, $height = null)
    {
        //get the source width and height
        $orgWidth = imagesx($this->resource);
        $orgHeight = imagesy($this->resource);

        //set the width if none is defined
        if (is_null($width)) {
            $width = $orgWidth;
        }

        //set the height if none is defined
        if (is_null($height)) {
            $height = $orgHeight;
        }

        //if the width and height are the same as the originals
        if ($width == $orgWidth && $height == $orgHeight) {
            //there's no need to process
            return $this;
        }

        //if we are here then we do need to crop
        //create the new resource with the width and height
        $scale = imagecreatetruecolor($width, $height);

        //render the image
        imagecopyresampled($scale, $this->resource, 0, 0, 0, 0, $width, $height, $orgWidth, $orgHeight);

        //destroy the original resource
        imagedestroy($this->resource);

        //assign the new resource
        $this->resource = $scale;

        return $this;
    }
public function scale ( $ width = null , $ height = null ) { //get the source width and height $ orgWidth = imagesx ( $ this -> resource ) ; $ orgHeight = imagesy ( $ this -> resource ) ; //set the width if none is defined if ( is_null ( $ width ) ) { $ width = $ orgWidth ; } //set the height if none is defined if ( is_null ( $ height ) ) { $ height = $ orgHeight ; } //if the width and height are the same as the originals if ( $ width == $ orgWidth && $ height == $ orgHeight ) { //there's no need to process return $ this ; } //if we are here then we do need to crop //create the new resource with the width and height $ scale = imagecreatetruecolor ( $ width , $ height ) ; //render the image imagecopyresampled ( $ scale , $ this -> resource , 0 , 0 , 0 , 0 , $ width , $ height , $ orgWidth , $ orgHeight ) ; //destroy the original resource imagedestroy ( $ this -> resource ) ; //assign the new resource $ this -> resource = $ scale ; return $ this ; }
Scales the image. If width or height is set
to null a width or height will be auto determined based on the
aspect ratio

@param int|null $width  The width; if null will use the original width
@param int|null $height The height; if null will use the original height

@return ImageHandler
Scales the image . If width or height is set to null a width or height will be auto determined based on the aspect ratio