]> granicus.if.org Git - graphviz/commitdiff
fix bug#795 - compiling diffimg without png or jpeg
authorellson <devnull@localhost>
Tue, 18 Oct 2005 21:06:20 +0000 (21:06 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 21:06:20 +0000 (21:06 +0000)
contrib/diffimg/Makefile.am
contrib/diffimg/diffimg.c

index 52b7aa2fd7cd8f9a694d95ded2997a757efafae6..8f9e777e30c1c102558cd7d39656980ea23f3790 100644 (file)
@@ -2,7 +2,7 @@
 
 VERSION=0.2
 
-AM_CPPFLAGS = -DVERSION="$(VERSION)" @GD_INCLUDES@
+AM_CPPFLAGS = @GD_INCLUDES@
 
 noinst_PROGRAMS = diffimg
 
index 74808b03880881fc3730f1aada5ac67d58e82b63..73937e22f7e22456007e3d588ce66b1844a29eb8 100644 (file)
  * John Ellson <ellson@research.att.com>
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);