From 4207255b1ac728caccad224c6cfa6308ad5b152d Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 18 Oct 2005 21:06:20 +0000 Subject: [PATCH] fix bug#795 - compiling diffimg without png or jpeg --- contrib/diffimg/Makefile.am | 2 +- contrib/diffimg/diffimg.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/contrib/diffimg/Makefile.am b/contrib/diffimg/Makefile.am index 52b7aa2fd..8f9e777e3 100644 --- a/contrib/diffimg/Makefile.am +++ b/contrib/diffimg/Makefile.am @@ -2,7 +2,7 @@ VERSION=0.2 -AM_CPPFLAGS = -DVERSION="$(VERSION)" @GD_INCLUDES@ +AM_CPPFLAGS = @GD_INCLUDES@ noinst_PROGRAMS = diffimg diff --git a/contrib/diffimg/diffimg.c b/contrib/diffimg/diffimg.c index 74808b038..73937e22f 100644 --- a/contrib/diffimg/diffimg.c +++ b/contrib/diffimg/diffimg.c @@ -26,6 +26,10 @@ * John Ellson */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -92,12 +96,30 @@ static gdImagePtr imageLoad (char *filename) } } im = 0; - if (strcasecmp(ext, ".png") == 0) + if (strcasecmp(ext, ".png") == 0) { +#ifdef HAVE_GD_PNG im = gdImageCreateFromPng(f); - else if (strcasecmp(ext, ".gif") == 0) +#else + fprintf(stderr, "PNG support is not available\n"); + exit(EX_UNAVAILABLE); +#endif + } + else if (strcasecmp(ext, ".gif") == 0) { +#ifdef HAVE_GD_GIF im = gdImageCreateFromGif(f); - else if (strcasecmp(ext, ".jpg") == 0) +#else + fprintf(stderr, "GIF support is not available\n"); + exit(EX_UNAVAILABLE); +#endif + } + else if (strcasecmp(ext, ".jpg") == 0) { +#ifdef HAVE_GD_JPEG im = gdImageCreateFromJpeg(f); +#else + fprintf(stderr, "JPEG support is not available\n"); + exit(EX_UNAVAILABLE); +#endif + } fclose(f); if (!im) { fprintf(stderr, "Loading image from file \"%s\" failed!\n", filename); @@ -130,8 +152,10 @@ int main(int argc, char **argv) gdImagePtr A, B, C; unsigned char black, white; unsigned int minSX, minSY, maxSX, maxSY; - FILE *f; bool rc; +#ifdef HAVE_GD_PNG + FILE *f; +#endif if (argc < 3) { fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n"); @@ -155,12 +179,17 @@ int main(int argc, char **argv) rc = imageDiff (A, B, C, minSX, minSY, black, white); +#ifdef HAVE_GD_PNG if ((argc > 3) && ((f = fopen(argv[3], "wb")))) { gdImagePng (C, f); fclose(f); } else gdImagePng (C, stdout); +#else + + fprintf(stderr, "PNG output support is not available\n"); +#endif gdImageDestroy(A); gdImageDestroy(B); -- 2.40.0