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