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