1--TEST--
2test_image_equals_file(): comparing palette images
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if (!(imagetypes() & IMG_PNG)) {
8    die("skip No PNG support");
9}
10?>
11--FILE--
12<?php
13require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';
14
15$im = imagecreate(10, 10);
16imagecolorallocate($im, 255, 255, 255);
17$red = imagecolorallocate($im, 255, 0, 0);
18imagefilledrectangle($im, 3,3, 7,7, $red);
19
20$filename = __DIR__ . DIRECTORY_SEPARATOR . 'test_image_equals_file_palette.png';
21imagepng($im, $filename);
22
23$im = imagecreate(10, 10);
24imagecolorallocate($im, 255, 255, 255);
25$blue = imagecolorallocate($im, 0, 0, 255);
26imagefilledrectangle($im, 3,3, 7,7, $blue);
27
28test_image_equals_file($filename, $im);
29
30$im = imagecreate(10, 10);
31imagecolorallocate($im, 255, 255, 255);
32imagecolorallocate($im, 0, 0, 0);
33$red = imagecolorallocate($im, 255, 0, 0);
34imagefilledrectangle($im, 3,3, 7,7, $red);
35
36test_image_equals_file($filename, $im);
37?>
38--EXPECT--
39The images differ in 25 pixels.
40The images are equal.
41--CLEAN--
42<?php
43unlink(__DIR__ . DIRECTORY_SEPARATOR . 'test_image_equals_file_palette.png');
44?>
45