ImageResize.php
private function getCropRectangle($image, $targetBox, $horzMode, $vertMode)
	{
		$imageBox = $image->getSize();
		$kw = $imageBox->getWidth() / $targetBox->getWidth();
		$kh = $imageBox->getHeight() / $targetBox->getHeight();
		$x = $y = $w = $h = 0;
		if($kh > $kw) {
			$x = 0;
			$w = $imageBox->getWidth();
			$h = $targetBox->getHeight() * $kw;
			switch ($vertMode) {
				case self::CROP_TOP:
					$y = 0;
					break;
				case self::CROP_BOTTOM:
					$y = $imageBox->getHeight() - $h;
					break;
				case self::CROP_CENTER:
					$y = ($imageBox->getHeight() - $h) / 2;
					break;
			}
		} else {
			$y = 0;
			$h = $imageBox->getHeight();
			$w  = $targetBox->getWidth() * $kh;
			switch ($horzMode) {
				case self::CROP_LEFT:
					$x = 0;
					break;
				case self::CROP_RIGHT:
					$x = $imageBox->getWidth() - $w;
					break;
				case self::CROP_CENTER:
					$x = ($imageBox->getWidth() - $w) / 2;
					break;
			}
		}
		return [$x, $y, $w, $h];
	}
private function getCropRectangle($image, $targetBox, $horzMode, $vertMode)
	{
		$imageBox = $image->getSize();
		$kw = $imageBox->getWidth() / $targetBox->getWidth();
		$kh = $imageBox->getHeight() / $targetBox->getHeight();
		$x = $y = $w = $h = 0;
		if($kh > $kw) {
			$x = 0;
			$w = $imageBox->getWidth();
			$h = $targetBox->getHeight() * $kw;
			switch ($vertMode) {
				case self::CROP_TOP:
					$y = 0;
					break;
				case self::CROP_BOTTOM:
					$y = $imageBox->getHeight() - $h;
					break;
				case self::CROP_CENTER:
					$y = ($imageBox->getHeight() - $h) / 2;
					break;
			}
		} else {
			$y = 0;
			$h = $imageBox->getHeight();
			$w  = $targetBox->getWidth() * $kh;
			switch ($horzMode) {
				case self::CROP_LEFT:
					$x = 0;
					break;
				case self::CROP_RIGHT:
					$x = $imageBox->getWidth() - $w;
					break;
				case self::CROP_CENTER:
					$x = ($imageBox->getWidth() - $w) / 2;
					break;
			}
		}
		return [$x, $y, $w, $h];
	}
private function getCropRectangle ( $ image , $ targetBox , $ horzMode , $ vertMode ) { $ imageBox = $ image -> getSize ( ) ; $ kw = $ imageBox -> getWidth ( ) / $ targetBox -> getWidth ( ) ; $ kh = $ imageBox -> getHeight ( ) / $ targetBox -> getHeight ( ) ; $ x = $ y = $ w = $ h = 0 ; if ( $ kh > $ kw ) { $ x = 0 ; $ w = $ imageBox -> getWidth ( ) ; $ h = $ targetBox -> getHeight ( ) * $ kw ; switch ( $ vertMode ) { case self :: CROP_TOP : $ y = 0 ; break ; case self :: CROP_BOTTOM : $ y = $ imageBox -> getHeight ( ) - $ h ; break ; case self :: CROP_CENTER : $ y = ( $ imageBox -> getHeight ( ) - $ h ) / 2 ; break ; } } else { $ y = 0 ; $ h = $ imageBox -> getHeight ( ) ; $ w = $ targetBox -> getWidth ( ) * $ kh ; switch ( $ horzMode ) { case self :: CROP_LEFT : $ x = 0 ; break ; case self :: CROP_RIGHT : $ x = $ imageBox -> getWidth ( ) - $ w ; break ; case self :: CROP_CENTER : $ x = ( $ imageBox -> getWidth ( ) - $ w ) / 2 ; break ; } } return [ $ x , $ y , $ w , $ h ] ; }
Get crop rectangle for custom thumbnail mode

@param ImageInterface $image
@param Box $targetBox
@param string $horzMode
@param string $vertMode
@return int[]
Get crop rectangle for custom thumbnail mode