xref: /PHP-7.2/ext/gd/tests/bug70102.phpt (revision 6d0e7732)
1--TEST--
2Bug #70102 (imagecreatefromwebm() shifts colors)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
7    die("skip test requires GD 2.2.0 or higher");
8}
9if (!function_exists('imagewebp') || !function_exists('imagecreatefromwebp'))
10    die('skip WebP support not available');
11?>
12--FILE--
13<?php
14$filename = __DIR__ .  '/bug70102.webp';
15
16$im = imagecreatetruecolor(8, 8);
17$white = imagecolorallocate($im, 255, 255, 255);
18var_dump($white & 0xffffff);
19imagefilledrectangle($im, 0, 0, 7, 7, $white);
20imagewebp($im, $filename);
21imagedestroy($im);
22
23$im = imagecreatefromwebp($filename);
24$color = imagecolorat($im, 4, 4);
25var_dump($color & 0xffffff);
26?>
27--CLEAN--
28<?php
29unlink(__DIR__ . '/bug70102.webp');
30?>
31--EXPECT--
32int(16777215)
33int(16777215)
34