Created
February 19, 2013 14:19
-
-
Save styks1987/4986314 to your computer and use it in GitHub Desktop.
Change lines 70-98 of the CropTransformer.php to allow the ability to directly pass coordinates for cropping.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!is_array($location)){ | |
if ($widthScale > $heightScale) { | |
$src_w = round($width * $heightScale); | |
// Position horizontally in the middle | |
if ($location === self::CENTER) { | |
$src_x = round(($baseWidth / 2) - (($width / 2) * $heightScale)); | |
// Position at the far right | |
} else if ($location === self::RIGHT || $location === self::BOTTOM) { | |
$src_x = $baseWidth - $src_w; | |
} | |
// Source height is larger, use width scale as the base | |
} else { | |
$src_h = round($height * $widthScale); | |
// Position vertically in the middle | |
if ($location === self::CENTER) { | |
$src_y = round(($baseHeight / 2) - (($height / 2) * $widthScale)); | |
// Position at the bottom | |
} else if ($location === self::RIGHT || $location === self::BOTTOM) { | |
$src_y = $baseHeight - $src_h; | |
} | |
} | |
}else{ | |
list($src_x, $src_y, $src_w, $src_h) = $location; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment