From 09d4aa30101d0d078c2f14032b73f9181259b505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Tue, 27 Oct 2020 09:06:12 +0100 Subject: [PATCH] Enable theming background transparency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/theming/lib/Controller/ThemingController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index b7e783b9cd..241f88dde6 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -285,13 +285,17 @@ class ThemingController extends Controller { // either to big or are not progressive rendering. $newImage = @imagecreatefromstring(file_get_contents($image['tmp_name'], 'r')); + // Preserve transparency + imagesavealpha($newImage, true); + imagealphablending($newImage, true); + $tmpFile = $this->tempManager->getTemporaryFile(); $newWidth = imagesx($newImage) < 4096 ? imagesx($newImage) : 4096; $newHeight = imagesy($newImage) / (imagesx($newImage) / $newWidth); $outputImage = imagescale($newImage, $newWidth, $newHeight); imageinterlace($outputImage, 1); - imagejpeg($outputImage, $tmpFile, 75); + imagepng($outputImage, $tmpFile, 8); imagedestroy($outputImage); $target->putContent(file_get_contents($tmpFile, 'r'));