From 7c246369d205e6383e518ba91f9bade52de1e4fe Mon Sep 17 00:00:00 2001 From: szaimen Date: Wed, 28 Jul 2021 13:46:28 +0200 Subject: [PATCH] improve logic when images will be converted Signed-off-by: szaimen --- apps/theming/lib/ImageManager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index b5ace6c968e6f..bdbffa76cd1c4 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -224,9 +224,9 @@ public function updateImage(string $key, string $tmpFile) { throw new \Exception('Unsupported image type'); } - if ($key === 'background' && strpos($detectedMimeType, 'image/svg') === false && strpos($detectedMimeType, 'image/gif') === false) { - // Optimize the image since some people may upload images that will be - // either to big or are not progressive rendering. + // Convert the background image if the size is bigger than 10 MB or if it is no background image and the size is bigger than 2 MB + if (($key === 'background' && filesize($tmpFile) > 10 * 1024 * 1024) || ($key !== 'background' && filesize($tmpFile) > 2 * 1024 * 1024)) { + $newImage = @imagecreatefromstring(file_get_contents($tmpFile)); // Preserve transparency