xref: /php-src/ext/gd/tests/bug66590.phpt (revision a375d547)
1--TEST--
2Bug #66590 (imagewebp() doesn't pad to even length)
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
8    die("skip test requires GD 2.2.0 or higher");
9}
10if (!function_exists('imagewebp')) die('skip WebP support not available');
11?>
12--FILE--
13<?php
14$filename = __DIR__ . '/bug66590.webp';
15$im = imagecreatetruecolor(75, 75);
16$red = imagecolorallocate($im, 255, 0, 0);
17imagefilledrectangle($im, 0, 0, 74, 74, $red);
18imagewebp($im, $filename);
19$stream = fopen($filename, 'rb');
20fread($stream, 4); // skip "RIFF"
21$length = fread($stream, 4);
22fclose($stream);
23$length = unpack('V', $length)[1] + 8;
24var_dump($length === filesize($filename));
25?>
26--CLEAN--
27<?php
28@unlink(__DIR__ . '/bug66590.webp');
29?>
30--EXPECT--
31bool(true)
32