xref: /PHP-8.3/ext/gd/tests/png2gd.phpt (revision 0aaad46c)
1--TEST--
2png <--> gd1/gd2 conversion test
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7    if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8        die("skip test requires GD 2.3.2 or older");
9    }
10
11    if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) {
12        die("skip png support unavailable");
13    }
14?>
15--FILE--
16<?php
17    $cwd = __DIR__;
18
19    echo "PNG to GD1 conversion: ";
20    echo imagegd(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test_png.gd1") ? 'ok' : 'failed';
21    echo "\n";
22
23    echo "PNG to GD2 conversion: ";
24    echo imagegd2(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test_png.gd2") ? 'ok' : 'failed';
25    echo "\n";
26
27    echo "GD1 to PNG conversion: ";
28    echo imagepng(imagecreatefromgd($cwd . "/test_png.gd1"), $cwd . "/test_gd1.png") ? 'ok' : 'failed';
29    echo "\n";
30
31    echo "GD2 to PNG conversion: ";
32    echo imagepng(imagecreatefromgd2($cwd . "/test_png.gd2"), $cwd . "/test_gd2.png") ? 'ok' : 'failed';
33    echo "\n";
34
35    @unlink($cwd . "/test_png.gd1");
36    @unlink($cwd . "/test_png.gd2");
37    @unlink($cwd . "/test_gd1.png");
38    @unlink($cwd . "/test_gd2.png");
39?>
40--EXPECT--
41PNG to GD1 conversion: ok
42PNG to GD2 conversion: ok
43GD1 to PNG conversion: ok
44GD2 to PNG conversion: ok
45