From 3e4e05bb93f3047e354e3ce256c0c697d287d386 Mon Sep 17 00:00:00 2001 From: =?utf8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Sun, 25 Oct 2020 19:15:52 +0100 Subject: [PATCH] Enable theming background transparency MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/theming/lib/ImageManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index 3fe76899dcd..5c2f2d01796 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -228,13 +228,17 @@ class ImageManager { // either to big or are not progressive rendering. $newImage = @imagecreatefromstring(file_get_contents($tmpFile)); + // Preserve transparency + imagesavealpha($newImage, true); + imagealphablending($newImage, true); + $tmpFile = $this->tempManager->getTemporaryFile(); $newWidth = (int)(imagesx($newImage) < 4096 ? imagesx($newImage) : 4096); $newHeight = (int)(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)); -- 2.39.5