Bug #77198 [Asn->Csd]: auto cropping has insufficient precision

From: Date: Sun, 25 Nov 2018 15:00:32 +0000
Subject: Bug #77198 [Asn->Csd]: auto cropping has insufficient precision
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218128@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77198&edit=1 ID: 77198 Updated by: cmb@php.net Reported by: cmb@php.net Summary: auto cropping has insufficient precision -Status: Assigned +Status: Closed Type: Bug Package: GD related Operating System: * PHP Version: 7.2.12 Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=b47b8886dd17d080c74c401f7893ba9f4ccb83d3 Log: Fix #77198: auto cropping has insufficient precision Previous Comments: ------------------------------------------------------------------------ [2018-11-25 13:45:10] cmb@php.net Description: ------------ Forwarding from upstream[1] since PHP's bundled libgd is affected as well. Consider, for instance, an 8x8 pixel image with a white background with a single black pixel anywhere (except for the corners). Applying gdImageCropAuto(…, GD_CROP_SIDES) is supposed to yield a 1x1 pixel image with a black pixel. The test script is exercising this for all 60 possible black pixel positions. [1] <https://github.com/libgd/libgd/issues/485> Test script: --------------- <?php function createWhiteImageWithBlackPixelAt($x, $y) { $im = imagecreatetruecolor(8, 8); imagefilledrectangle($im, 0, 0, 7, 7, 0xffffff); imagesetpixel($im, $x, $y, 0x000000); return $im; } $count = 0; for ($y = 0; $y < 8; $y++) { for ($x = 0; $x < 8; $x++) { if (($x == 0 && ($y == 0 || $y == 7)) || ($x == 7 && ($y == 0 || $y == 7))) { continue; // skip the corners } $orig = createWhiteImageWithBlackPixelAt($x, $y); $cropped = imagecropauto($orig, IMG_CROP_SIDES); if ($cropped) { if (imagesx($cropped) === 1 && imagesy($cropped) === 1 && imagecolorat($cropped, 0, 0) === 0x000000) { $count++; } imagedestroy($cropped); } imagedestroy($orig); } } echo "$count\n"; Expected result: ---------------- 60 Actual result: -------------- 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77198&edit=1

« previous php.bugs (#218128) next »