1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Attempt fix for processwire/processwire-issues#1299 using @adrianbj suggestion

This commit is contained in:
Ryan Cramer
2022-12-29 12:20:20 -05:00
parent 1b76b92f8c
commit f57a07e15a

View File

@@ -862,12 +862,13 @@ class ImageSizerEngineGD extends ImageSizerEngine {
} else if($this->imageType == IMAGETYPE_GIF) { } else if($this->imageType == IMAGETYPE_GIF) {
// @mrx GIF transparency // @mrx GIF transparency
$transparentIndex = imagecolortransparent($image); $transparentIndex = imagecolortransparent($image);
// $transparentColor = $transparentIndex != -1 ? @imagecolorsforindex($image, $transparentIndex) : 0; if($transparentIndex >= 0 && $transparentIndex < imagecolorstotal($image)) {
$transparentColor = $transparentIndex != -1 ? imagecolorsforindex($image, ($transparentIndex < imagecolorstotal($image) ? $transparentIndex : $transparentIndex - 1)) : 0; $transparentColor = imagecolorsforindex($image, $transparentIndex);
if(!empty($transparentColor)) { if(!empty($transparentColor)) {
$transparentNew = imagecolorallocate($im, $transparentColor['red'], $transparentColor['green'], $transparentColor['blue']); $transparentNew = imagecolorallocate($im, $transparentColor['red'], $transparentColor['green'], $transparentColor['blue']);
$transparentNewIndex = imagecolortransparent($im, $transparentNew); $transparentNewIndex = imagecolortransparent($im, $transparentNew);
imagefill($im, 0, 0, $transparentNewIndex); imagefill($im, 0, 0, $transparentNewIndex);
}
} }
} else { } else {