Skip to content

Commit 875661e

Browse files
authored
Fixed truecolor detection for WebP images (#3403)
1 parent f578a5c commit 875661e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/Varien/Image/Adapter/Gd2.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,19 @@ private function _getTransparency($imageResource, $fileType, &$isAlpha = false,
302302
{
303303
$isAlpha = false;
304304
$isTrueColor = false;
305-
// assume that transparency is supported by gif/png only
306-
if ((IMAGETYPE_GIF === $fileType) || (IMAGETYPE_PNG === $fileType)) {
305+
// assume that transparency is supported by gif/png/webp only
306+
if (($fileType === IMAGETYPE_GIF) || ($fileType === IMAGETYPE_PNG) || ($fileType === IMAGETYPE_WEBP)) {
307307
// check for specific transparent color
308308
$transparentIndex = imagecolortransparent($imageResource);
309309
if ($transparentIndex >= 0) {
310310
return $transparentIndex;
311-
} elseif (IMAGETYPE_PNG === $fileType) { // assume that truecolor PNG has transparency
312-
$isAlpha = $this->checkAlpha($this->_fileName);
311+
} elseif ($fileType === IMAGETYPE_PNG || $fileType === IMAGETYPE_WEBP) {
312+
$isAlpha = $this->checkAlpha($this->_fileName);
313313
$isTrueColor = true;
314314
return $transparentIndex; // -1
315315
}
316316
}
317-
if (IMAGETYPE_JPEG === $fileType) {
317+
if ($fileType === IMAGETYPE_JPEG) {
318318
$isTrueColor = true;
319319
}
320320
return false;

0 commit comments

Comments
 (0)