From: Alexander Ebert Date: Tue, 13 Jul 2021 14:31:03 +0000 (+0200) Subject: Saving WebP images in GD requires a True Color palette X-Git-Tag: 5.4.0~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=db206eb06f121ab866e688779ed1ed1de4154522;p=GitHub%2FWoltLab%2FWCF.git Saving WebP images in GD requires a True Color palette https://stackoverflow.com/questions/39292617/fatal-error-paletter-image-not-supported-by-webp/47469726#47469726 --- diff --git a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php index 674cf649bb..6e654a8aaa 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php @@ -402,6 +402,7 @@ class GDImageAdapter implements IImageAdapter, IWebpImageAdapter } elseif ($this->type == \IMAGETYPE_PNG) { \imagepng($image); } elseif ($this->type == \IMAGETYPE_WEBP) { + \imagepalettetotruecolor($image); \imagewebp($image); } elseif (\function_exists('imageJPEG')) { \imagejpeg($image, null, 90); @@ -593,6 +594,7 @@ class GDImageAdapter implements IImageAdapter, IWebpImageAdapter break; case "webp": + \imagepalettetotruecolor($image); \imagewebp($image, null, $quality); break;