xref: /PHP-8.0/ext/gd/tests/bug66590.phpt (revision 6d0e7732)
1--TEST--
2Bug #66590 (imagewebp() doesn't pad to even length)
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')) die('skip WebP support not available');
10?>
11--FILE--
12<?php
13$filename = __DIR__ . '/bug66590.webp';
14$im = imagecreatetruecolor(75, 75);
15$red = imagecolorallocate($im, 255, 0, 0);
16imagefilledrectangle($im, 0, 0, 74, 74, $red);
17imagewebp($im, $filename);
18$stream = fopen($filename, 'rb');
19fread($stream, 4); // skip "RIFF"
20$length = fread($stream, 4);
21fclose($stream);
22$length = unpack('V', $length)[1] + 8;
23var_dump($length === filesize($filename));
24?>
25--CLEAN--
26<?php
27@unlink(__DIR__ . '/bug66590.webp');
28?>
29--EXPECT--
30bool(true)
31