xref: /PHP-7.4/ext/gd/tests/bug73291.phpt (revision dcad13e8)
1--TEST--
2Bug #73291 (imagecropauto() $threshold differs from external libgd)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6?>
7--FILE--
8<?php
9
10$src = imagecreatetruecolor(255, 255);
11$white = imagecolorallocate($src, 255, 255, 255);
12imagefilledrectangle($src, 0, 0, 254, 254, $white);
13
14for ($i = 254; $i > 0; $i--) {
15    $color = imagecolorallocate($src, $i, $i, $i);
16    imagefilledellipse($src, 127, 127, $i, $i, $color);
17}
18
19foreach ([0.1, 0.5, 1.0, 10.0] as $threshold) {
20    $dst = imagecropauto($src, IMG_CROP_THRESHOLD, $threshold, $white);
21    if ($dst !== false) {
22        printf("size: %d*%d\n", imagesx($dst), imagesy($dst));
23    } else {
24        echo "cropped to zero size\n";
25    }
26}
27
28?>
29===DONE===
30--EXPECT--
31size: 247*247
32size: 237*237
33size: 229*229
34size: 175*175
35===DONE===
36