From a0c8cc7e46cf0a0d8ada1040bf526d6701a5260a Mon Sep 17 00:00:00 2001 From: Heiner Gassen Date: Sat, 23 Jan 2016 22:49:46 +0100 Subject: [PATCH] Fix errors with transparent gifs Fixes error "imagecolorsforindex(): Color index XXX out of range" by checking with the pallet size of the image. --- CImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CImage.php b/CImage.php index 604bc76..4a17f32 100644 --- a/CImage.php +++ b/CImage.php @@ -2224,7 +2224,7 @@ private function createImageKeepTransparency($width, $height) ? imagecolortransparent($this->image) : -1; - if ($index != -1) { + if ($index >= 0 && $index < imagecolorstotal($this->image)) { imagealphablending($img, true); $transparent = imagecolorsforindex($this->image, $index);