]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/ImageService.php
Update settings.php
[bookstack] / app / Uploads / ImageService.php
index e7668471bd64c174c858eef0ac6c9c36a16e8880..756149fe7a1bacdc2f11a2f4ee3672ceb50c8676 100644 (file)
@@ -254,7 +254,16 @@ class ImageService extends UploadService
         } else {
             $thumb->fit($width, $height);
         }
-        return (string)$thumb->encode();
+
+        $thumbData = (string)$thumb->encode();
+
+        // Use original image data if we're keeping the ratio
+        // and the resizing does not save any space.
+        if ($keepRatio && strlen($thumbData) > strlen($imageData)) {
+            return $imageData;
+        }
+
+        return $thumbData;
     }
 
     /**