1--TEST-- 2Bug #75124 (gdImageGrayScale() may produce colors) 3--SKIPIF-- 4<?php 5if (!extension_loaded('gd')) die('skip gd extension not available'); 6if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<')) { 7 die('skip only for bundled libgd or external libgd >= 2.2.5'); 8} 9?> 10--FILE-- 11<?php 12$im = imagecreatefrompng(__DIR__ . '/bug75124.png'); 13var_dump(imageistruecolor($im)); 14imagefilter($im, IMG_FILTER_GRAYSCALE); 15for ($i = 0, $width = imagesx($im); $i < $width; $i ++) { 16 for ($j = 0, $height = imagesy($im); $j < $height; $j++) { 17 $color = imagecolorat($im, $i, $j); 18 $red = ($color >> 16) & 0xff; 19 $green = ($color >> 8) & 0xff; 20 $blue = $color & 0xff; 21 if ($red != $green || $green != $blue) { 22 echo "non grayscale pixel detected\n"; 23 break 2; 24 } 25 } 26} 27?> 28===DONE=== 29--EXPECT-- 30bool(true) 31===DONE=== 32