protected function prepareDimensions($width, $height, $scaleMethod)
	{
		// Instantiate variables.
		$dimensions = new \stdClass;

		switch ($scaleMethod)
		{
			case self::SCALE_FILL:
				$dimensions->width = (int) round($width);
				$dimensions->height = (int) round($height);
				break;

			case self::SCALE_INSIDE:
			case self::SCALE_OUTSIDE:
			case self::SCALE_FIT:
				$rx = ($width > 0) ? ($this->getWidth() / $width) : 0;
				$ry = ($height > 0) ? ($this->getHeight() / $height) : 0;

				if ($scaleMethod != self::SCALE_OUTSIDE)
				{
					$ratio = max($rx, $ry);
				}
				else
				{
					$ratio = min($rx, $ry);
				}

				$dimensions->width = (int) round($this->getWidth() / $ratio);
				$dimensions->height = (int) round($this->getHeight() / $ratio);
				break;

			default:
				throw new \InvalidArgumentException('Invalid scale method.');
				break;
		}

		return $dimensions;
	}
protected function prepareDimensions($width, $height, $scaleMethod)
	{
		// Instantiate variables.
		$dimensions = new \stdClass;

		switch ($scaleMethod)
		{
			case self::SCALE_FILL:
				$dimensions->width = (int) round($width);
				$dimensions->height = (int) round($height);
				break;

			case self::SCALE_INSIDE:
			case self::SCALE_OUTSIDE:
			case self::SCALE_FIT:
				$rx = ($width > 0) ? ($this->getWidth() / $width) : 0;
				$ry = ($height > 0) ? ($this->getHeight() / $height) : 0;

				if ($scaleMethod != self::SCALE_OUTSIDE)
				{
					$ratio = max($rx, $ry);
				}
				else
				{
					$ratio = min($rx, $ry);
				}

				$dimensions->width = (int) round($this->getWidth() / $ratio);
				$dimensions->height = (int) round($this->getHeight() / $ratio);
				break;

			default:
				throw new \InvalidArgumentException('Invalid scale method.');
				break;
		}

		return $dimensions;
	}
protected function prepareDimensions ( $ width , $ height , $ scaleMethod ) { // Instantiate variables. $ dimensions = new \ stdClass ; switch ( $ scaleMethod ) { case self :: SCALE_FILL : $ dimensions -> width = ( int ) round ( $ width ) ; $ dimensions -> height = ( int ) round ( $ height ) ; break ; case self :: SCALE_INSIDE : case self :: SCALE_OUTSIDE : case self :: SCALE_FIT : $ rx = ( $ width > 0 ) ? ( $ this -> getWidth ( ) / $ width ) : 0 ; $ ry = ( $ height > 0 ) ? ( $ this -> getHeight ( ) / $ height ) : 0 ; if ( $ scaleMethod != self :: SCALE_OUTSIDE ) { $ ratio = max ( $ rx , $ ry ) ; } else { $ ratio = min ( $ rx , $ ry ) ; } $ dimensions -> width = ( int ) round ( $ this -> getWidth ( ) / $ ratio ) ; $ dimensions -> height = ( int ) round ( $ this -> getHeight ( ) / $ ratio ) ; break ; default : throw new \ InvalidArgumentException ( 'Invalid scale method.' ) ; break ; } return $ dimensions ; }
Method to get the new dimensions for a resized image.

@param   integer  $width        The width of the resized image in pixels.
@param   integer  $height       The height of the resized image in pixels.
@param   integer  $scaleMethod  The method to use for scaling

@return  \stdClass

@since   1.0
@throws  \InvalidArgumentException  If width, height or both given as zero
Method to get the new dimensions for a resized image .