1--TEST-- 2Bug #77198 (threshold cropping has insufficient precision) 3--EXTENSIONS-- 4gd 5--SKIPIF-- 6<?php 7if (!GD_BUNDLED) die('skip upstream bugfix has not been released'); 8?> 9--FILE-- 10<?php 11 12function createWhiteImageWithBlackPixelAt($x, $y) 13{ 14 $im = imagecreatetruecolor(8, 8); 15 imagefilledrectangle($im, 0, 0, 7, 7, 0xffffff); 16 imagesetpixel($im, $x, $y, 0x000000); 17 return $im; 18} 19 20for ($y = 0; $y < 8; $y++) { 21 for ($x = 0; $x < 8; $x++) { 22 $orig = createWhiteImageWithBlackPixelAt($x, $y); 23 $cropped = imagecropauto($orig, IMG_CROP_THRESHOLD, 1, 0xffffff); 24 if (!$cropped) { 25 printf("Pixel at %d, %d: unexpected NULL crop\n", $x, $y); 26 } else { 27 $width = imagesx($cropped); 28 if ($width !== 1) { 29 printf("Pixel at %d, %d: unexpected width (%d)\n", $x, $y, $width); 30 } 31 $height = imagesy($cropped); 32 if ($height !== 1) { 33 printf("Pixel at %d, %d: unexpected height (%d)\n", $x, $y, $height); 34 } 35 $color = imagecolorat($cropped, 0, 0); 36 if ($color !== 0x000000) { 37 printf("Pixel at %d, %d: unexpected color (%d)\n", $x, $y, $color); 38 } 39 imagedestroy($cropped); 40 } 41 imagedestroy($orig); 42 } 43} 44 45?> 46===DONE=== 47--EXPECT-- 48===DONE=== 49