From 875661e3c23cdc465ae088ab7a73da23346afdb3 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 24 Jul 2023 20:53:16 +0100 Subject: [PATCH] Fixed truecolor detection for WebP images (#3403) --- lib/Varien/Image/Adapter/Gd2.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Varien/Image/Adapter/Gd2.php b/lib/Varien/Image/Adapter/Gd2.php index 2776380bc56..b1754785aeb 100644 --- a/lib/Varien/Image/Adapter/Gd2.php +++ b/lib/Varien/Image/Adapter/Gd2.php @@ -302,19 +302,19 @@ private function _getTransparency($imageResource, $fileType, &$isAlpha = false, { $isAlpha = false; $isTrueColor = false; - // assume that transparency is supported by gif/png only - if ((IMAGETYPE_GIF === $fileType) || (IMAGETYPE_PNG === $fileType)) { + // assume that transparency is supported by gif/png/webp only + if (($fileType === IMAGETYPE_GIF) || ($fileType === IMAGETYPE_PNG) || ($fileType === IMAGETYPE_WEBP)) { // check for specific transparent color $transparentIndex = imagecolortransparent($imageResource); if ($transparentIndex >= 0) { return $transparentIndex; - } elseif (IMAGETYPE_PNG === $fileType) { // assume that truecolor PNG has transparency - $isAlpha = $this->checkAlpha($this->_fileName); + } elseif ($fileType === IMAGETYPE_PNG || $fileType === IMAGETYPE_WEBP) { + $isAlpha = $this->checkAlpha($this->_fileName); $isTrueColor = true; return $transparentIndex; // -1 } } - if (IMAGETYPE_JPEG === $fileType) { + if ($fileType === IMAGETYPE_JPEG) { $isTrueColor = true; } return false;