src/UI/Image/Processing.php
public function scaleDownToLimit( $width, $height, $interpolate = TRUE )
	{
		if( !is_int( $width ) )
			throw new InvalidArgumentException( 'Width must be integer' );
		if( !is_int( $height ) )
			throw new InvalidArgumentException( 'Height must be integer' );
		$sourceWidth	= $this->image->getWidth();
		$sourceHeight	= $this->image->getHeight();
		if( $sourceWidth <= $width && $sourceHeight <= $height )
			return FALSE;
		$scale = 1;
		if( $sourceWidth > $width )
			$scale	*= $width / $sourceWidth;
		if( $sourceHeight * $scale > $height )
			$scale	*= $height / ( $sourceHeight * $scale );
		$width	= (int) round( $sourceWidth * $scale );
		$height	= (int) round( $sourceHeight * $scale );
		return $this->resize( $width, $height, $interpolate );
	}
public function scaleDownToLimit( $width, $height, $interpolate = TRUE )
	{
		if( !is_int( $width ) )
			throw new InvalidArgumentException( 'Width must be integer' );
		if( !is_int( $height ) )
			throw new InvalidArgumentException( 'Height must be integer' );
		$sourceWidth	= $this->image->getWidth();
		$sourceHeight	= $this->image->getHeight();
		if( $sourceWidth <= $width && $sourceHeight <= $height )
			return FALSE;
		$scale = 1;
		if( $sourceWidth > $width )
			$scale	*= $width / $sourceWidth;
		if( $sourceHeight * $scale > $height )
			$scale	*= $height / ( $sourceHeight * $scale );
		$width	= (int) round( $sourceWidth * $scale );
		$height	= (int) round( $sourceHeight * $scale );
		return $this->resize( $width, $height, $interpolate );
	}
public function scaleDownToLimit ( $ width , $ height , $ interpolate = TRUE ) { if ( ! is_int ( $ width ) ) throw new InvalidArgumentException ( 'Width must be integer' ) ; if ( ! is_int ( $ height ) ) throw new InvalidArgumentException ( 'Height must be integer' ) ; $ sourceWidth = $ this -> image -> getWidth ( ) ; $ sourceHeight = $ this -> image -> getHeight ( ) ; if ( $ sourceWidth <= $ width && $ sourceHeight <= $ height ) return FALSE ; $ scale = 1 ; if ( $ sourceWidth > $ width ) $ scale *= $ width / $ sourceWidth ; if ( $ sourceHeight * $ scale > $ height ) $ scale *= $ height / ( $ sourceHeight * $ scale ) ; $ width = ( int ) round ( $ sourceWidth * $ scale ) ; $ height = ( int ) round ( $ sourceHeight * $ scale ) ; return $ this -> resize ( $ width , $ height , $ interpolate ) ; }
Scales image down to a maximum size if larger than limit.
@access		public
@param		integer		$width			Maximum width
@param		integer		$height			Maximum height
@param		boolean		$interpolate	Flag: use interpolation
@return		boolean		Image has been scaled
Scales image down to a maximum size if larger than limit .