Skip to content

Commit

Permalink
Fixed truecolor detection for WebP images (OpenMage#3403)
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano authored Jul 24, 2023
1 parent f578a5c commit 875661e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 875661e

Please sign in to comment.