public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO )
    {
        switch( $aspectRatioMode )
        {
            case AspectRatioMode::IGNORE_ASPECT_RATIO:
                break;
            case AspectRatioMode::KEEP_ASPECT_RATIO:
                $height = ($width * $this->getHeight()) / $this->getWidth();
                break;
            case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING:
                $width = ($height * $this->getWidth()) / $this->getHeight();
                break;
        }

        $newResource = imagecreatetruecolor( $width, $height );

        imagealphablending( $newResource, false );
        imagesavealpha( $newResource, true );
        imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );

        $newImage = MImage::fromResource( $newResource );
        $newImage->type = $this->type;

        return $newImage;
    }
public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO )
    {
        switch( $aspectRatioMode )
        {
            case AspectRatioMode::IGNORE_ASPECT_RATIO:
                break;
            case AspectRatioMode::KEEP_ASPECT_RATIO:
                $height = ($width * $this->getHeight()) / $this->getWidth();
                break;
            case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING:
                $width = ($height * $this->getWidth()) / $this->getHeight();
                break;
        }

        $newResource = imagecreatetruecolor( $width, $height );

        imagealphablending( $newResource, false );
        imagesavealpha( $newResource, true );
        imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );

        $newImage = MImage::fromResource( $newResource );
        $newImage->type = $this->type;

        return $newImage;
    }
public function scaled ( $ width , $ height , $ aspectRatioMode = AspectRatioMode :: IGNORE_ASPECT_RATIO ) { switch ( $ aspectRatioMode ) { case AspectRatioMode :: IGNORE_ASPECT_RATIO : break ; case AspectRatioMode :: KEEP_ASPECT_RATIO : $ height = ( $ width * $ this -> getHeight ( ) ) / $ this -> getWidth ( ) ; break ; case AspectRatioMode :: KEEP_ASPECT_RATIO_BY_EXPANDING : $ width = ( $ height * $ this -> getWidth ( ) ) / $ this -> getHeight ( ) ; break ; } $ newResource = imagecreatetruecolor ( $ width , $ height ) ; imagealphablending ( $ newResource , false ) ; imagesavealpha ( $ newResource , true ) ; imagecopyresampled ( $ newResource , $ this -> resource , 0 , 0 , 0 , 0 , $ width , $ height , $ this -> getWidth ( ) , $ this -> getHeight ( ) ) ; $ newImage = MImage :: fromResource ( $ newResource ) ; $ newImage -> type = $ this -> type ; return $ newImage ; }
Returns a copy of the image scaled to a rectangle with the given width
and height according to the given aspectRatioMode and transformMode.
If either the width or the height is zero or negative,
this function returns a null image.

@param int $width
@param int $height
@param int|AspectRatioMode $aspectRatioMode
@return MImage Description
Returns a copy of the image scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode . If either the width or the height is zero or negative this function returns a null image .