8
#include <unistd.h> /* For unlink function */
13
/* A short program which converts a .png file into a .gd file, for
14
your convenience in creating images on the fly from a
15
basis image that must be loaded quickly. The .gd format
16
is not intended to be a general-purpose format. */
18
void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2);
21
int main(int argc, char **argv)
27
fprintf(stderr, "Usage: gdcmpgif filename.gif filename.gif\n");
30
in = fopen(argv[1], "rb");
32
fprintf(stderr, "Input file does not exist!\n");
35
im1 = gdImageCreateFromGif(in);
39
fprintf(stderr, "Input is not in GIF format!\n");
43
in = fopen(argv[2], "rb");
45
fprintf(stderr, "Input file 2 does not exist!\n");
48
im2 = gdImageCreateFromGif(in);
52
fprintf(stderr, "Input 2 is not in GIF format!\n");
56
CompareImages("gdcmpgif", im1, im2);
64
void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2)
68
cmpRes = gdImageCompare(im1, im2);
70
if (cmpRes & GD_CMP_IMAGE) {
71
printf("%%%s: ERROR images differ: BAD\n",msg);
72
} else if (cmpRes != 0) {
73
printf("%%%s: WARNING images differ: WARNING - Probably OK\n",msg);
75
printf("%%%s: OK\n",msg);
79
if (cmpRes & (GD_CMP_SIZE_X + GD_CMP_SIZE_Y)) {
80
printf("-%s: INFO image sizes differ\n",msg);
83
if (cmpRes & GD_CMP_NUM_COLORS) {
84
printf("-%s: INFO number of palette entries differ %d Vs. %d\n",msg,
85
im1->colorsTotal, im2->colorsTotal);
88
if (cmpRes & GD_CMP_COLOR) {
89
printf("-%s: INFO actual colours of pixels differ\n",msg);