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