Skip to content

Commit

Permalink
Convert palette images to truecolor before outputting WebP
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscris committed Feb 9, 2025
1 parent 5d5254c commit 7c0d5d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions formwork/src/Images/Handler/WebpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ protected function setDataFromGdImage(GdImage $gdImage): void
{
imagesavealpha($gdImage, true);

if (!imageistruecolor($gdImage)) {
imagepalettetotruecolor($gdImage);
}

ob_start();

if (imagewebp($gdImage, null, $this->options['webpQuality']) === false) {
Expand Down

0 comments on commit 7c0d5d3

Please sign in to comment.