Bug #77198 [NEW]: auto cropping has insufficient precision

From: Date: Sun, 25 Nov 2018 13:45:10 +0000
Subject: Bug #77198 [NEW]: auto cropping has insufficient precision
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218126@lists.php.net to get a copy of this message
From: cmb Operating system: * PHP version: 7.2.12 Package: GD related Bug Type: Bug Bug description:auto cropping has insufficient precision 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 bug report at https://bugs.php.net/bug.php?id=77198&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77198&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77198&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77198&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77198&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77198&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77198&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77198&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77198&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77198&r=support Expected behavior: https://bugs.php.net/fix.php?id=77198&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77198&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77198&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77198&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77198&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77198&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77198&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77198&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77198&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77198&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77198&r=mysqlcfg

« previous php.bugs (#218126) next »