1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00
Files
archived-php-src/ext/gd/tests/bug73291.phpt
T
Christoph M. Becker dcad13e8c9 Fix #73291: imagecropauto() $threshold differs from external libgd
Since upstream does not appear to move in any way[1], we sync our
behavior.  Even though the BC break is ugly (which is the reason we
target master only), having to deal with different algorithms is even
worse for portable userland code.

[1] <https://github.com/libgd/libgd/issues/334>
2018-12-01 18:49:30 +01:00

36 lines
827 B
PHP

--TEST--
Bug #73291 (imagecropauto() $threshold differs from external libgd)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
$src = imagecreatetruecolor(255, 255);
$white = imagecolorallocate($src, 255, 255, 255);
imagefilledrectangle($src, 0, 0, 254, 254, $white);
for ($i = 254; $i > 0; $i--) {
$color = imagecolorallocate($src, $i, $i, $i);
imagefilledellipse($src, 127, 127, $i, $i, $color);
}
foreach ([0.1, 0.5, 1.0, 10.0] as $threshold) {
$dst = imagecropauto($src, IMG_CROP_THRESHOLD, $threshold, $white);
if ($dst !== false) {
printf("size: %d*%d\n", imagesx($dst), imagesy($dst));
} else {
echo "cropped to zero size\n";
}
}
?>
===DONE===
--EXPECT--
size: 247*247
size: 237*237
size: 229*229
size: 175*175
===DONE===