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