(fix): stop resolution pre-check from clobbering requested crop dimensions

This commit is contained in:
Chirag Aggarwal committed 2026-07-03 18:06:44 +05:30
1 parent 1ad94992ab
commit fa04473661
1 file changed
+5 -5
@@ -245,15 +245,15 @@ class Get extends Action
$maxArea = \Imagick::getResourceLimit(\Imagick::RESOURCETYPE_AREA);
$dimensions = \getimagesizefromstring($source);
if ($dimensions !== false) {
[$width, $height] = $dimensions;
[$sourceWidth, $sourceHeight] = $dimensions;
if (
($maxWidth > 0 && $width > $maxWidth) ||
($maxHeight > 0 && $height > $maxHeight) ||
($maxArea > 0 && $width * $height > $maxArea)
($maxWidth > 0 && $sourceWidth > $maxWidth) ||
($maxHeight > 0 && $sourceHeight > $maxHeight) ||
($maxArea > 0 && $sourceWidth * $sourceHeight > $maxArea)
) {
throw new Exception(
Exception::STORAGE_IMAGE_RESOLUTION_EXCEEDED,
\sprintf('Image resolution %dx%d exceeds the maximum allowed %dx%d or %d total pixels', $width, $height, $maxWidth, $maxHeight, $maxArea)
\sprintf('Image resolution %dx%d exceeds the maximum allowed %dx%d or %d total pixels', $sourceWidth, $sourceHeight, $maxWidth, $maxHeight, $maxArea)
);
}
}