diff --git a/.gitignore b/.gitignore index a00615f96678e..c427f0da64af7 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,7 @@ tests/*/*/*.sh */tests/*/*/*.sh */*/tests/*.diff */*/tests/*.out +*/*/tests/*.out.png */*/tests/*.php */*/tests/*.exp */*/tests/*.log diff --git a/ext/gd/tests/bug22544.phpt b/ext/gd/tests/bug22544.phpt index 4c8f763a7348b..3d4335d461506 100644 --- a/ext/gd/tests/bug22544.phpt +++ b/ext/gd/tests/bug22544.phpt @@ -8,16 +8,13 @@ Bug #22544 (TrueColor transparency in PNG images). ?> --FILE-- --EXPECT-- -10a57d09a2c63fad87b85b38d6b258d6 +The images are equal. diff --git a/ext/gd/tests/bug22544.png b/ext/gd/tests/bug22544.png new file mode 100644 index 0000000000000..5e6251f440385 Binary files /dev/null and b/ext/gd/tests/bug22544.png differ diff --git a/ext/gd/tests/func.inc b/ext/gd/tests/func.inc index f17227eccda5e..01ba83102ec15 100644 --- a/ext/gd/tests/func.inc +++ b/ext/gd/tests/func.inc @@ -59,3 +59,71 @@ function get_libxpm_version() return $version; } +/** + * Tests that an in-memory image equals a PNG file. + * + * It checks for equal image sizes, and whether any pixels are different. + * The textual result is printed, so the EXPECT section should contain the line + * "The images are equal." + * + * If the PNG file does not exists, or the images are not equal, a diagnostic + * message is printed, and the actual file is stored right beside the temporary + * .php test file with the extension .out.png, to be able to manually inspect + * the result. + * + * @param string $filename + * @param resource $actual + * @return void + */ +function test_image_equals_file($filename, $actual) +{ + if (!file_exists($filename)) { + echo "The expected image does not exist.\n"; + save_actual_image($actual); + return; + } + $expected = imagecreatefrompng($filename); + $exp_x = imagesx($expected); + $exp_y = imagesy($expected); + $act_x = imagesx($actual); + $act_y = imagesy($actual); + if ($exp_x != $act_x || $exp_y != $act_y) { + echo "The image size differs: expected {$exp_x}x{$exp_y}, got {$act_x}x{$act_y}.\n"; + save_actual_image($actual); + imagedestroy($expected); + return; + } + $pixels_changed = 0; + for ($y = 0; $y < $exp_y; $y++) { + for ($x = 0; $x < $exp_x; $x ++) { + $exp_c = imagecolorat($expected, $x, $y); + $act_c = imagecolorat($actual, $x, $y); + if ($exp_c != $act_c) { + $pixels_changed++; + } + } + } + if (!$pixels_changed) { + echo "The images are equal.\n"; + } else { + echo "The images differ in {$pixels_changed} pixels.\n"; + save_actual_image($actual); + } + imagedestroy($expected); +} + +/** + * Saves an actual image to disk. + * + * The image is saved right beside the temporary .php test file with the + * extension .out.png. + * + * @param resource $image + * @return void + */ +function save_actual_image($image) +{ + $pathinfo = pathinfo($_SERVER['SCRIPT_FILENAME']); + $filename = "{$pathinfo['dirname']}/{$pathinfo['filename']}.out.png"; + imagepng($image, $filename); +} diff --git a/ext/gd/tests/imagearc_basic.phpt b/ext/gd/tests/imagearc_basic.phpt index 4647dd1e3f990..b4761f2399c1d 100644 --- a/ext/gd/tests/imagearc_basic.phpt +++ b/ext/gd/tests/imagearc_basic.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc with white color imagearc($image, 50, 50, 30, 30, 0, 180, $white); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagearc_basic.png', $image); ?> --EXPECT-- -f18ad8001afefee2e9b8c08d6884425b +The images are equal. diff --git a/ext/gd/tests/imagearc_basic.png b/ext/gd/tests/imagearc_basic.png new file mode 100644 index 0000000000000..42a4d68988a9a Binary files /dev/null and b/ext/gd/tests/imagearc_basic.png differ diff --git a/ext/gd/tests/imagearc_error1.phpt b/ext/gd/tests/imagearc_error1.phpt index 423f0356af974..1e63406832816 100644 --- a/ext/gd/tests/imagearc_error1.phpt +++ b/ext/gd/tests/imagearc_error1.phpt @@ -17,13 +17,9 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc with white color imagearc($image, 50, 50, 30, 30, 0, 180); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagearc_error1.png', $image); ?> --EXPECTF-- Warning: imagearc() expects exactly 8 parameters, 7 given in %s on line %d -abebb25b5a2813cfbf92f1f24365786a +The images are equal. diff --git a/ext/gd/tests/imagearc_error1.png b/ext/gd/tests/imagearc_error1.png new file mode 100644 index 0000000000000..9cbff6e164f3c Binary files /dev/null and b/ext/gd/tests/imagearc_error1.png differ diff --git a/ext/gd/tests/imagearc_variation1.phpt b/ext/gd/tests/imagearc_variation1.phpt index 568d3a6d47b90..1b36eedf2905e 100644 --- a/ext/gd/tests/imagearc_variation1.phpt +++ b/ext/gd/tests/imagearc_variation1.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc with white color imagearc($image, 50, 50, 30, 30, 0, -90, $white); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagearc_variation1.png', $image); ?> --EXPECT-- -ed2c8427a9922dfd8a105f10a88a0d20 +The images are equal. diff --git a/ext/gd/tests/imagearc_variation1.png b/ext/gd/tests/imagearc_variation1.png new file mode 100644 index 0000000000000..8bc15c423f4de Binary files /dev/null and b/ext/gd/tests/imagearc_variation1.png differ diff --git a/ext/gd/tests/imagearc_variation2.phpt b/ext/gd/tests/imagearc_variation2.phpt index 045c68e61c20f..40227c3750f56 100644 --- a/ext/gd/tests/imagearc_variation2.phpt +++ b/ext/gd/tests/imagearc_variation2.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc with white color imagearc($image, 50, 50, 30, 30, -90, 0, $white); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagearc_variation2.png', $image); ?> --EXPECT-- -463b4aea9d9acfab30016ee92613c779 +The images are equal. diff --git a/ext/gd/tests/imagearc_variation2.png b/ext/gd/tests/imagearc_variation2.png new file mode 100644 index 0000000000000..40779ed457d3f Binary files /dev/null and b/ext/gd/tests/imagearc_variation2.png differ diff --git a/ext/gd/tests/imagechar_basic.phpt b/ext/gd/tests/imagechar_basic.phpt index 7e5fa931bcf2d..f238aabae4598 100644 --- a/ext/gd/tests/imagechar_basic.phpt +++ b/ext/gd/tests/imagechar_basic.phpt @@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255); $result = imagechar($image, 1, 5, 5, 'C', $white); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagechar_basic.png', $image); ?> --EXPECT-- -e94962ac28ad03bd4142cb1abe9ef98b +The images are equal. diff --git a/ext/gd/tests/imagechar_basic.png b/ext/gd/tests/imagechar_basic.png new file mode 100644 index 0000000000000..a01222aab84ce Binary files /dev/null and b/ext/gd/tests/imagechar_basic.png differ diff --git a/ext/gd/tests/imagecharup_basic.phpt b/ext/gd/tests/imagecharup_basic.phpt index 54c8dfaa4a561..50b0a596133a4 100644 --- a/ext/gd/tests/imagecharup_basic.phpt +++ b/ext/gd/tests/imagecharup_basic.phpt @@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255); $result = imagecharup($image, 1, 5, 5, 'C', $white); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagecharup_basic.png', $image); ?> --EXPECT-- -79b48d5cef6d489bb68573df0296d775 +The images are equal. diff --git a/ext/gd/tests/imagecharup_basic.png b/ext/gd/tests/imagecharup_basic.png new file mode 100644 index 0000000000000..e9628658ff2fd Binary files /dev/null and b/ext/gd/tests/imagecharup_basic.png differ diff --git a/ext/gd/tests/imagecolorallocatealpha_basic.phpt b/ext/gd/tests/imagecolorallocatealpha_basic.phpt index 720c50098a9dc..a311073b71146 100644 --- a/ext/gd/tests/imagecolorallocatealpha_basic.phpt +++ b/ext/gd/tests/imagecolorallocatealpha_basic.phpt @@ -17,14 +17,10 @@ $corA = imagecolorallocatealpha($img, 50, 100, 255, 50); $half = imagefilledarc ( $img, 75, 75, 70, 70, 0, 180, $cor, IMG_ARC_PIE ); $half2 = imagefilledarc ( $img, 75, 75, 70, 70, 180, 360, $corA, IMG_ARC_PIE ); -ob_start(); -imagepng($img, null, 9); -$imgsrc = ob_get_contents(); -ob_end_clean(); - -var_dump(md5(base64_encode($imgsrc))); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagecolorallocatealpha_basic.png', $img); var_dump($corA); ?> --EXPECT-- -string(32) "b856a0b1a15efe0f79551ebbb5651fe8" +The images are equal. int(842163455) \ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_basic.png b/ext/gd/tests/imagecolorallocatealpha_basic.png new file mode 100644 index 0000000000000..73048b73bbc86 Binary files /dev/null and b/ext/gd/tests/imagecolorallocatealpha_basic.png differ diff --git a/ext/gd/tests/imagecolorset_basic.phpt b/ext/gd/tests/imagecolorset_basic.phpt index a1776ff50fceb..f051a2202f768 100644 --- a/ext/gd/tests/imagecolorset_basic.phpt +++ b/ext/gd/tests/imagecolorset_basic.phpt @@ -23,13 +23,9 @@ $bg = imagecolorat($im, 0, 0); // Set the backgrund to be blue imagecolorset($im, $bg, 0, 0, 255); -// Get output and generate md5 hash -ob_start(); -imagepng($im, null, 9); -$result_image = ob_get_contents(); -ob_end_clean(); -echo md5(base64_encode($result_image)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagecolorset_basic.png', $im); imagedestroy($im); ?> --EXPECT-- -6f2002aafb57b2d275fad6a6258d7476 +The images are equal. diff --git a/ext/gd/tests/imagecolorset_basic.png b/ext/gd/tests/imagecolorset_basic.png new file mode 100644 index 0000000000000..b9e77d116932d Binary files /dev/null and b/ext/gd/tests/imagecolorset_basic.png differ diff --git a/ext/gd/tests/imageconvolution_basic.phpt b/ext/gd/tests/imageconvolution_basic.phpt index 5a9aa8f95b3ec..972de76f86f97 100644 --- a/ext/gd/tests/imageconvolution_basic.phpt +++ b/ext/gd/tests/imageconvolution_basic.phpt @@ -22,12 +22,8 @@ $gaussian = array( imageconvolution($image, $gaussian, 16, 0); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imageconvolution_basic.png', $image); ?> --EXPECT-- -594576a2a2a689447ffc07eb5a73f09b +The images are equal. diff --git a/ext/gd/tests/imageconvolution_basic.png b/ext/gd/tests/imageconvolution_basic.png new file mode 100644 index 0000000000000..0558a1bb36782 Binary files /dev/null and b/ext/gd/tests/imageconvolution_basic.png differ diff --git a/ext/gd/tests/imagecreatetruecolor_basic.phpt b/ext/gd/tests/imagecreatetruecolor_basic.phpt index 5c85f52380cba..e2a5a09fbaea5 100644 --- a/ext/gd/tests/imagecreatetruecolor_basic.phpt +++ b/ext/gd/tests/imagecreatetruecolor_basic.phpt @@ -11,12 +11,8 @@ Rafael Dohms --EXPECT-- -5a8fe9864cbd20e5dbe730c77f30db95 +The images are equal. diff --git a/ext/gd/tests/imagecreatetruecolor_basic.png b/ext/gd/tests/imagecreatetruecolor_basic.png new file mode 100644 index 0000000000000..1728cb4d80ebc Binary files /dev/null and b/ext/gd/tests/imagecreatetruecolor_basic.png differ diff --git a/ext/gd/tests/imageellipse_basic.phpt b/ext/gd/tests/imageellipse_basic.phpt index bfd0b79f584e1..f3b1e10bfeaed 100644 --- a/ext/gd/tests/imageellipse_basic.phpt +++ b/ext/gd/tests/imageellipse_basic.phpt @@ -16,12 +16,8 @@ $image = imagecreatetruecolor(400, 300); // Draw a white ellipse imageellipse($image, 200, 150, 300, 200, 16777215); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imageellipse_basic.png', $image); ?> --EXPECT-- -d8b9bc2ca224bd68569413f4617f8e1f +The images are equal. diff --git a/ext/gd/tests/imageellipse_basic.png b/ext/gd/tests/imageellipse_basic.png new file mode 100644 index 0000000000000..7dda55a186986 Binary files /dev/null and b/ext/gd/tests/imageellipse_basic.png differ diff --git a/ext/gd/tests/imagefilledarc_basic.phpt b/ext/gd/tests/imagefilledarc_basic.phpt index 9ff9bd3716839..f09f337f5146f 100644 --- a/ext/gd/tests/imagefilledarc_basic.phpt +++ b/ext/gd/tests/imagefilledarc_basic.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc and fill it with white color imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white, IMG_ARC_PIE); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilledarc_basic.png', $image); ?> --EXPECT-- -894f394c7f2e2364642ef27fea6bfc33 +The images are equal. diff --git a/ext/gd/tests/imagefilledarc_basic.png b/ext/gd/tests/imagefilledarc_basic.png new file mode 100644 index 0000000000000..3a16097df9d7b Binary files /dev/null and b/ext/gd/tests/imagefilledarc_basic.png differ diff --git a/ext/gd/tests/imagefilledarc_error1.phpt b/ext/gd/tests/imagefilledarc_error1.phpt index b2bc4172de33c..81d04358fbbde 100644 --- a/ext/gd/tests/imagefilledarc_error1.phpt +++ b/ext/gd/tests/imagefilledarc_error1.phpt @@ -17,13 +17,9 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc and fill it with white color imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilledarc_error1.png', $image); ?> --EXPECTF-- Warning: imagefilledarc() expects exactly 9 parameters, 8 given in %s on line %d -abebb25b5a2813cfbf92f1f24365786a +The images are equal. diff --git a/ext/gd/tests/imagefilledarc_error1.png b/ext/gd/tests/imagefilledarc_error1.png new file mode 100644 index 0000000000000..9cbff6e164f3c Binary files /dev/null and b/ext/gd/tests/imagefilledarc_error1.png differ diff --git a/ext/gd/tests/imagefilledarc_variation1.phpt b/ext/gd/tests/imagefilledarc_variation1.phpt index 2dec1ead2cb08..9bd1b4437b654 100644 --- a/ext/gd/tests/imagefilledarc_variation1.phpt +++ b/ext/gd/tests/imagefilledarc_variation1.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc and fill it with white color imagefilledarc($image, 50, 50, 30, 30, 0, -25, $white, IMG_ARC_PIE); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilledarc_variation1.png', $image); ?> --EXPECT-- -b77bbb8207e5adbebfcc8bd1c4074305 +The images are equal. diff --git a/ext/gd/tests/imagefilledarc_variation1.png b/ext/gd/tests/imagefilledarc_variation1.png new file mode 100644 index 0000000000000..391115058ae45 Binary files /dev/null and b/ext/gd/tests/imagefilledarc_variation1.png differ diff --git a/ext/gd/tests/imagefilledarc_variation2.phpt b/ext/gd/tests/imagefilledarc_variation2.phpt index 5c8ffba0014d1..15b6efd084c11 100644 --- a/ext/gd/tests/imagefilledarc_variation2.phpt +++ b/ext/gd/tests/imagefilledarc_variation2.phpt @@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an arc and fill it with white color imagefilledarc($image, 50, 50, 30, 30, -25, 25, $white, IMG_ARC_PIE); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilledarc_variation2.png', $image); ?> --EXPECT-- -b8b572812b3c85678f6c38c4ecca7619 +The images are equal. diff --git a/ext/gd/tests/imagefilledarc_variation2.png b/ext/gd/tests/imagefilledarc_variation2.png new file mode 100644 index 0000000000000..6b29ec6265f90 Binary files /dev/null and b/ext/gd/tests/imagefilledarc_variation2.png differ diff --git a/ext/gd/tests/imagefilledellipse_basic.phpt b/ext/gd/tests/imagefilledellipse_basic.phpt index a1a578ad43f2f..1dee961b13be9 100644 --- a/ext/gd/tests/imagefilledellipse_basic.phpt +++ b/ext/gd/tests/imagefilledellipse_basic.phpt @@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); //create an ellipse and fill it with white color imagefilledellipse($image, 50, 50, 40, 30, $white); -ob_start(); -imagepng($image); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilledellipse_basic.png', $image); ?> --EXPECT-- -9ba540bba1b78c9f08efaa6fa0afd93b +The images are equal. diff --git a/ext/gd/tests/imagefilledellipse_basic.png b/ext/gd/tests/imagefilledellipse_basic.png new file mode 100644 index 0000000000000..8a56bec57409f Binary files /dev/null and b/ext/gd/tests/imagefilledellipse_basic.png differ diff --git a/ext/gd/tests/imagefilltoborder_basic.phpt b/ext/gd/tests/imagefilltoborder_basic.phpt index 80b84d2c6960b..843eed473d23b 100644 --- a/ext/gd/tests/imagefilltoborder_basic.phpt +++ b/ext/gd/tests/imagefilltoborder_basic.phpt @@ -21,13 +21,9 @@ imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); // Fill border imagefilltoborder( $image, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); -ob_start(); -imagepng( $image, null, 9 ); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagefilltoborder_basic.png', $image); ?> --EXPECT-- -847ec236f1c4d14c465306c8408550fc +The images are equal. diff --git a/ext/gd/tests/imagefilltoborder_basic.png b/ext/gd/tests/imagefilltoborder_basic.png new file mode 100644 index 0000000000000..7c163e3c49983 Binary files /dev/null and b/ext/gd/tests/imagefilltoborder_basic.png differ diff --git a/ext/gd/tests/imagegammacorrect_basic.phpt b/ext/gd/tests/imagegammacorrect_basic.phpt index b568728e7140b..88a159802e2e3 100644 --- a/ext/gd/tests/imagegammacorrect_basic.phpt +++ b/ext/gd/tests/imagegammacorrect_basic.phpt @@ -18,15 +18,11 @@ $half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $grey, IMG_ARC_PIE ); $half2 = imagefilledarc ( $image, 75, 75, 70, 70, 0, -180, $gray, IMG_ARC_PIE ); $gamma = imagegammacorrect($image, 1, 5); +var_dump((bool) $gamma); -if ($gamma){ - ob_start(); - imagepng($image, null, 9); - $img = ob_get_contents(); - ob_end_clean(); -} - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagegammacorrect_basic.png', $image); ?> --EXPECT-- -30639772903913594bc665743e1b9ab8 +bool(true) +The images are equal. diff --git a/ext/gd/tests/imagegammacorrect_basic.png b/ext/gd/tests/imagegammacorrect_basic.png new file mode 100644 index 0000000000000..0eb0b765a05de Binary files /dev/null and b/ext/gd/tests/imagegammacorrect_basic.png differ diff --git a/ext/gd/tests/imagegammacorrect_variation1.phpt b/ext/gd/tests/imagegammacorrect_variation1.phpt index cda96c62876c6..7e505c2f34c45 100644 --- a/ext/gd/tests/imagegammacorrect_variation1.phpt +++ b/ext/gd/tests/imagegammacorrect_variation1.phpt @@ -18,15 +18,11 @@ $half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $grey, IMG_ARC_PIE ); $half2 = imagefilledarc ( $image, 75, 75, 70, 70, 0, -180, $gray, IMG_ARC_PIE ); $gamma = imagegammacorrect($image, 1, 5); +var_dump((bool) $gamma); -if ($gamma){ - ob_start(); - imagepng($image, null, 9); - $img = ob_get_contents(); - ob_end_clean(); -} - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagegammacorrect_variation1.png', $image); ?> --EXPECT-- -7716c0905ae08bd84b4d6cba8969a42e +bool(true) +The images are equal. diff --git a/ext/gd/tests/imagegammacorrect_variation1.png b/ext/gd/tests/imagegammacorrect_variation1.png new file mode 100644 index 0000000000000..1e45025297496 Binary files /dev/null and b/ext/gd/tests/imagegammacorrect_variation1.png differ diff --git a/ext/gd/tests/imagelayereffect_basic.phpt b/ext/gd/tests/imagelayereffect_basic.phpt index a34e05e02f9cd..2c948fd0c51ce 100644 --- a/ext/gd/tests/imagelayereffect_basic.phpt +++ b/ext/gd/tests/imagelayereffect_basic.phpt @@ -13,15 +13,11 @@ Rafael Dohms $image = imagecreatetruecolor(180, 30); $layer = imagelayereffect($image, IMG_EFFECT_REPLACE); +var_dump((bool) $layer); -if ($layer){ - ob_start(); - imagepng($image, null, 9); - $img = ob_get_contents(); - ob_end_clean(); -} - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagelayereffect_basic.png', $image); ?> --EXPECT-- -5a8fe9864cbd20e5dbe730c77f30db95 +bool(true) +The images are equal. diff --git a/ext/gd/tests/imagelayereffect_basic.png b/ext/gd/tests/imagelayereffect_basic.png new file mode 100644 index 0000000000000..1728cb4d80ebc Binary files /dev/null and b/ext/gd/tests/imagelayereffect_basic.png differ diff --git a/ext/gd/tests/imagerectangle_basic.phpt b/ext/gd/tests/imagerectangle_basic.phpt index f706ee7ab6551..507d71532663c 100644 --- a/ext/gd/tests/imagerectangle_basic.phpt +++ b/ext/gd/tests/imagerectangle_basic.phpt @@ -15,13 +15,8 @@ $image = imagecreatetruecolor( 100, 100 ); // Draw a rectangle imagerectangle( $image, 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) ); -ob_start(); -imagepng( $image, null, 9 ); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); - +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagerectangle_basic.png', $image); ?> --EXPECT-- -282aaecfdd50091821d63093d9bb1bb9 \ No newline at end of file +The images are equal. diff --git a/ext/gd/tests/imagerectangle_basic.png b/ext/gd/tests/imagerectangle_basic.png new file mode 100644 index 0000000000000..dcb4d2e630453 Binary files /dev/null and b/ext/gd/tests/imagerectangle_basic.png differ diff --git a/ext/gd/tests/imagesetbrush_basic.phpt b/ext/gd/tests/imagesetbrush_basic.phpt index 790184ddc29c4..e1a9c6a80c837 100644 --- a/ext/gd/tests/imagesetbrush_basic.phpt +++ b/ext/gd/tests/imagesetbrush_basic.phpt @@ -26,12 +26,8 @@ imagesetbrush($mainimg, $img); // Draw a couple of brushes, each overlaying each imageline($mainimg, 50, 50, 50, 60, IMG_COLOR_BRUSHED); -// Get output and generate md5 hash -ob_start(); -imagepng($mainimg, null, 9); -$result_image = ob_get_contents(); -ob_end_clean(); -echo md5(base64_encode($result_image)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagesetbrush_basic.png', $mainimg); ?> --EXPECT-- -8168577c0d1fe6d9d11397cb15263d82 +The images are equal. diff --git a/ext/gd/tests/imagesetbrush_basic.png b/ext/gd/tests/imagesetbrush_basic.png new file mode 100644 index 0000000000000..0242634db5465 Binary files /dev/null and b/ext/gd/tests/imagesetbrush_basic.png differ diff --git a/ext/gd/tests/imagesetthickness_basic.phpt b/ext/gd/tests/imagesetthickness_basic.phpt index a8b079bede6fc..3c91a886df04c 100644 --- a/ext/gd/tests/imagesetthickness_basic.phpt +++ b/ext/gd/tests/imagesetthickness_basic.phpt @@ -23,12 +23,8 @@ imagesetthickness($image, 5); // Draw the rectangle imagerectangle($image, 14, 14, 185, 85, $black); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagesetthickness_basic.png', $image); ?> --EXPECT-- -93c3077f1bdc372cd0b0db96db282985 \ No newline at end of file +The images are equal. diff --git a/ext/gd/tests/imagesetthickness_basic.png b/ext/gd/tests/imagesetthickness_basic.png new file mode 100644 index 0000000000000..e38e7dbe00ff7 Binary files /dev/null and b/ext/gd/tests/imagesetthickness_basic.png differ diff --git a/ext/gd/tests/imagestring_basic.phpt b/ext/gd/tests/imagestring_basic.phpt index adc68a67fe4af..311683f7af81c 100644 --- a/ext/gd/tests/imagestring_basic.phpt +++ b/ext/gd/tests/imagestring_basic.phpt @@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255); $result = imagestring($image, 1, 5, 5, 'String Text', $white); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagestring_basic.png', $image); ?> --EXPECT-- -d0d2fe757400cb7846b36a8c34b41e4a +The images are equal. diff --git a/ext/gd/tests/imagestring_basic.png b/ext/gd/tests/imagestring_basic.png new file mode 100644 index 0000000000000..7f9fd12c1268d Binary files /dev/null and b/ext/gd/tests/imagestring_basic.png differ diff --git a/ext/gd/tests/imagestringup_basic.phpt b/ext/gd/tests/imagestringup_basic.phpt index 0c748b6aa9d7d..015d375eded84 100644 --- a/ext/gd/tests/imagestringup_basic.phpt +++ b/ext/gd/tests/imagestringup_basic.phpt @@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255); $result = imagestringup($image, 1, 5, 25, 'Str', $white); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagestringup_basic.png', $image); ?> --EXPECT-- -7c28016adcf620b772af2a8655b87bd2 +The images are equal. diff --git a/ext/gd/tests/imagestringup_basic.png b/ext/gd/tests/imagestringup_basic.png new file mode 100644 index 0000000000000..875b5bae95549 Binary files /dev/null and b/ext/gd/tests/imagestringup_basic.png differ diff --git a/ext/gd/tests/imagetruecolortopalette_basic.phpt b/ext/gd/tests/imagetruecolortopalette_basic.phpt index b0a0394b55ce6..acb9b2836807c 100644 --- a/ext/gd/tests/imagetruecolortopalette_basic.phpt +++ b/ext/gd/tests/imagetruecolortopalette_basic.phpt @@ -19,13 +19,9 @@ $half2 = imagefilledarc ( $image, 75, 55, 80, 70, 0, -180, $b, IMG_ARC_PIE ); var_dump(imagetruecolortopalette($image, true, 2)); -ob_start(); -imagepng($image, null, 9); -$img = ob_get_contents(); -ob_end_clean(); - -echo md5(base64_encode($img)); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/imagetruecolortopalette_basic.png', $image); ?> --EXPECT-- bool(true) -0843f63ab2f9fddedd69b0b421686bc5 \ No newline at end of file +The images are equal. diff --git a/ext/gd/tests/imagetruecolortopalette_basic.png b/ext/gd/tests/imagetruecolortopalette_basic.png new file mode 100644 index 0000000000000..a36d960405440 Binary files /dev/null and b/ext/gd/tests/imagetruecolortopalette_basic.png differ diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt index abf4ee3339aa7..84f8858a9ae0a 100644 --- a/ext/gd/tests/libgd00100.phpt +++ b/ext/gd/tests/libgd00100.phpt @@ -106,14 +106,10 @@ $points = array( ); imagefilledpolygon($im, $points, 5, $black); -ob_start(); -imagepng($im); -$png = ob_get_contents(); -ob_end_clean(); - -echo md5($png); +include_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/libgd00100.png', $im); imagedestroy($im); ?> --EXPECTF-- -2e6cf558bb4dadf60c8b608d5f8cda4e +The images are equal. diff --git a/ext/gd/tests/libgd00100.png b/ext/gd/tests/libgd00100.png new file mode 100644 index 0000000000000..8d4f6a1be830e Binary files /dev/null and b/ext/gd/tests/libgd00100.png differ