jpeg2png.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. jpeg <--> png conversion test
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) {
  8. die("skip png support unavailable");
  9. }
  10. if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) {
  11. die("skip jpeg support unavailable");
  12. }
  13. ?>
  14. --FILE--
  15. <?php
  16. $cwd = __DIR__;
  17. echo "PNG to JPEG conversion: ";
  18. echo imagejpeg(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test_jpeg.jpeg") ? 'ok' : 'failed';
  19. echo "\n";
  20. echo "Generated JPEG to PNG conversion: ";
  21. echo imagepng(imagecreatefromjpeg($cwd . "/test_jpeg.jpeg"), $cwd . "/test_jpng.png") ? 'ok' : 'failed';
  22. echo "\n";
  23. echo "JPEG to PNG conversion: ";
  24. echo imagepng(imagecreatefromjpeg($cwd . "/conv_test.jpg"), $cwd . "/test_png.png") ? 'ok' : 'failed';
  25. echo "\n";
  26. echo "Generated PNG to JPEG conversion: ";
  27. echo imagejpeg(imagecreatefrompng($cwd . "/test_png.png"), $cwd . "/test_pjpeg.jpeg") ? 'ok' : 'failed';
  28. echo "\n";
  29. @unlink($cwd . "/test_jpeg.jpeg");
  30. @unlink($cwd . "/test_jpng.png");
  31. @unlink($cwd . "/test_png.png");
  32. @unlink($cwd . "/test_pjpeg.jpeg");
  33. ?>
  34. --EXPECT--
  35. PNG to JPEG conversion: ok
  36. Generated JPEG to PNG conversion: ok
  37. JPEG to PNG conversion: ok
  38. Generated PNG to JPEG conversion: ok