xref: /PHP-8.2/ext/gd/tests/bug67325.phpt (revision a375d547)
1--TEST--
2Bug #67325 (imagetruecolortopalette: white is duplicated in palette)
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.3', '<=')) {
8    die("skip test requires newer than GD 2.2.3");
9}
10 if (!(imagetypes() & IMG_JPG)) die('skip JPEG support not available');
11?>
12--FILE--
13<?php
14$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug67325.jpg';
15
16$im = imagecreatefromjpeg($filename);
17imagetruecolortopalette($im, 0, 256);
18
19$white = 0;
20for ($i = 0; $i < 256; $i++) {
21    $components = imagecolorsforindex($im, $i);
22    if ($components['red'] === 255 && $components['green'] === 255 && $components['blue'] === 255) {
23        $white++;
24    }
25}
26var_dump($white);
27
28imagedestroy($im);
29?>
30--EXPECT--
31int(0)
32