From fa04473661408cdd289c6103777015b1a458da50 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 3 Jul 2026 18:06:44 +0530 Subject: [PATCH] (fix): stop resolution pre-check from clobbering requested crop dimensions --- .../Modules/Storage/Http/Buckets/Files/Preview/Get.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php index a5562281d5..7ff22f3744 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php @@ -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) ); } }