bug66590.phpt 775 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Bug #66590 (imagewebp() doesn't pad to even length)
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
  8. die("skip test requires GD 2.2.0 or higher");
  9. }
  10. if (!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);
  17. imagefilledrectangle($im, 0, 0, 74, 74, $red);
  18. imagewebp($im, $filename);
  19. $stream = fopen($filename, 'rb');
  20. fread($stream, 4); // skip "RIFF"
  21. $length = fread($stream, 4);
  22. fclose($stream);
  23. $length = unpack('V', $length)[1] + 8;
  24. var_dump($length === filesize($filename));
  25. ?>
  26. --CLEAN--
  27. <?php
  28. @unlink(__DIR__ . '/bug66590.webp');
  29. ?>
  30. --EXPECT--
  31. bool(true)