public function resize($width = null, $height = null)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a number or null
            ->test(1, 'numeric', 'null')
            //Argument 2 must be a number or null
            ->test(2, 'numeric', '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;
        }

        $newWidth = $width;
        $newHeight = $height;

        //if the desired height is larger than the desired width
        if ($height < $width) {
            //get the width aspect ratio
            $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            //if the aspect width is bigger than the desired width
            if ($newWidth < $width) {
                //set it back to the desired width
                $width = $newWidth;
                //and adjust the height instead
                $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            }
        //if the desired height is smaller than the desired width
        } else {
            //get the width aspect ratio
            $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            //if the aspect height is bigger than the desired height
            if ($newHeight < $height) {
                //set it back to the desired height
                $height = $newHeight;
                //and adjust the width instead
                $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            }
        }

        return $this->scale($width, $height);
    }
public function resize($width = null, $height = null)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a number or null
            ->test(1, 'numeric', 'null')
            //Argument 2 must be a number or null
            ->test(2, 'numeric', '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;
        }

        $newWidth = $width;
        $newHeight = $height;

        //if the desired height is larger than the desired width
        if ($height < $width) {
            //get the width aspect ratio
            $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            //if the aspect width is bigger than the desired width
            if ($newWidth < $width) {
                //set it back to the desired width
                $width = $newWidth;
                //and adjust the height instead
                $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            }
        //if the desired height is smaller than the desired width
        } else {
            //get the width aspect ratio
            $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
            //if the aspect height is bigger than the desired height
            if ($newHeight < $height) {
                //set it back to the desired height
                $height = $newHeight;
                //and adjust the width instead
                $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
            }
        }

        return $this->scale($width, $height);
    }
public function resize ( $ width = null , $ height = null ) { //argument test Argument :: i ( ) //Argument 1 must be a number or null -> test ( 1 , 'numeric' , 'null' ) //Argument 2 must be a number or null -> test ( 2 , 'numeric' , '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 ; } $ newWidth = $ width ; $ newHeight = $ height ; //if the desired height is larger than the desired width if ( $ height < $ width ) { //get the width aspect ratio $ width = $ this -> getWidthAspectRatio ( $ orgWidth , $ orgHeight , $ height ) ; //if the aspect width is bigger than the desired width if ( $ newWidth < $ width ) { //set it back to the desired width $ width = $ newWidth ; //and adjust the height instead $ height = $ this -> getHeightAspectRatio ( $ orgWidth , $ orgHeight , $ width ) ; } //if the desired height is smaller than the desired width } else { //get the width aspect ratio $ height = $ this -> getHeightAspectRatio ( $ orgWidth , $ orgHeight , $ width ) ; //if the aspect height is bigger than the desired height if ( $ newHeight < $ height ) { //set it back to the desired height $ height = $ newHeight ; //and adjust the width instead $ width = $ this -> getWidthAspectRatio ( $ orgWidth , $ orgHeight , $ height ) ; } } return $ this -> scale ( $ width , $ height ) ; }
Resizes the image. This is a version of
scale but keeping it's original 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 Eden\Image\Index
Resizes the image . This is a version of scale but keeping it s original aspect ratio