diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 869880f..ac3c612 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,15 +1,22 @@ include_directories (BEFORE "${GD_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}") SET(TESTS_FILES - arc - crop - gif - nnquant - tgaread + gif ) +if (PNG_FOUND) + LIST(APPEND TEST_FILES arc crop tgaread) + + if (JPEG_FOUND) + LIST(APPEND TESTS_FILES copyrotated flip nnquantnnquant) + if (UNIX) + target_link_libraries(copyrotated m) + endif (UNIX) + endif (JPEG_FOUND) +endif (PNG_FOUND) + if (JPEG_FOUND) - LIST(APPEND TESTS_FILES copyrotated flip) + LIST(APPEND TESTS_FILES resize) endif (JPEG_FOUND) if (TIFF_FOUND) @@ -27,12 +34,6 @@ FOREACH(test_name ${TESTS_FILES}) target_link_libraries (${test_name} ${GD_LINK_LIB}) ENDFOREACH(test_name) -if(JPEG_FOUND) - if(UNIX) - target_link_libraries(copyrotated m) - endif(UNIX) -endif(JPEG_FOUND) - if (WIN32 AND NOT MINGW AND NOT MSYS) add_executable(windows WIN32 "windows.c") target_link_libraries (windows ${GD_LINK_LIB}) diff --git a/examples/arc.c b/examples/arc.c index 8e86283..ae3fcfd 100644 --- a/examples/arc.c +++ b/examples/arc.c @@ -19,11 +19,7 @@ int main() gdImageDestroy(im); return 1; } -#ifdef HAVE_LIBPNG gdImagePng(im, fp); -#else - printf("No PNG support. Cannot save image.\n"); -#endif fclose(fp); gdImageDestroy(im); diff --git a/examples/crop.c b/examples/crop.c index bafb6df..3e30b7f 100644 --- a/examples/crop.c +++ b/examples/crop.c @@ -12,11 +12,7 @@ void save_png(gdImagePtr im, const char *filename) fprintf(stderr, "Can't save png image %s\n", filename); return; } -#ifdef HAVE_LIBPNG gdImagePng(im, fp); -#else - printf("No PNG support. Cannot save image.\n"); -#endif fclose(fp); } @@ -30,12 +26,7 @@ gdImagePtr read_png(const char *filename) fprintf(stderr, "Can't read png image %s\n", filename); return NULL; } -#ifdef HAVE_LIBPNG im = gdImageCreateFromPng(fp); -#else - im = NULL; - printf("No PNG support. Cannot read image.\n"); -#endif fclose(fp); return im; } diff --git a/examples/nnquant.c b/examples/nnquant.c index 33ed523..91139b5 100644 --- a/examples/nnquant.c +++ b/examples/nnquant.c @@ -12,17 +12,12 @@ void save_png(gdImagePtr im, const char *filename) fprintf(stderr, "Can't save png image %s\n", filename); return; } -#ifdef HAVE_LIBPNG gdImagePng(im, fp); -#else - printf("No PNG support. Cannot save image.\n"); -#endif fclose(fp); } int main() { -#ifdef HAVE_JPEG gdImagePtr im, im2; FILE *fp; char path[2048]; @@ -56,9 +51,5 @@ int main() save_png(im, "a_jquant_dither.png"); gdImageDestroy(im); -#else - printf("JPEG support is required for this example. Please recompile GD with JPEG or change this example to use another format as input."); - return 1; -#endif return 0; } diff --git a/examples/tgaread.c b/examples/tgaread.c index a8e0807..1fa9daf 100644 --- a/examples/tgaread.c +++ b/examples/tgaread.c @@ -44,11 +44,7 @@ int main() gdImageDestroy(im); return 1; } -#ifdef HAVE_LIBPNG - gdImagePng(im, fp); -#else - printf("No PNG support. Cannot save image.\n"); -#endif + gdImagePng(im, fp); fclose(fp); gdImageDestroy(im); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0acdc2c..6230c1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -146,7 +146,7 @@ if (PNG_FOUND) endif() endif() -if (FREETYPE_FOUND) +if (FREETYPE_FOUND AND JPEG_FOUND) set(GD_PROGRAMS ${GD_PROGRAMS} annotate) endif() diff --git a/src/Makefile.am b/src/Makefile.am index caeb37e..377acc0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,9 @@ check_PROGRAMS += fontconfigtest endif if HAVE_LIBFREETYPE +if HAVE_LIBJPEG bin_PROGRAMS += annotate +endif check_PROGRAMS += gdtestft testtr endif diff --git a/src/annotate.c b/src/annotate.c index 00aaf49..e3c5285 100644 --- a/src/annotate.c +++ b/src/annotate.c @@ -16,17 +16,6 @@ enum { left, center, right }; int main(int argc, char *argv[]) { -#ifndef HAVE_LIBFREETYPE - (void)argc; - (void)argv; - - /* 2.0.12 */ - fprintf(stderr, "annotate is not useful without freetype.\n" - "Install freetype, then './configure; make clean; make install'\n" - "the gd library again.\n" - ); - return 1; -#else gdImagePtr im; char *iin, *iout; FILE *in, *out; @@ -70,12 +59,7 @@ int main(int argc, char *argv[]) exit(2); } -#ifdef HAVE_LIBJPEG im = gdImageCreateFromJpeg(in); -#else - fprintf(stderr, "No JPEG library support available.\n"); - exit(1); -#endif fclose(in); @@ -200,13 +184,8 @@ badLine: fprintf(stderr, "Cannot create %s\n", iout); exit(5); } -#ifdef HAVE_LIBJPEG gdImageJpeg(im, out, 95); -#else - fprintf(stderr, "No JPEG library support available.\n"); -#endif gdImageDestroy(im); fclose(out); return 0; -#endif /* HAVE_LIBFREETYPE */ } diff --git a/src/circletexttest.c b/src/circletexttest.c index 0f20a34..5345151 100644 --- a/src/circletexttest.c +++ b/src/circletexttest.c @@ -8,10 +8,6 @@ int main(void) { /* 2.0.22: can't depend on PNG either */ -#ifndef HAVE_LIBPNG - fprintf(stderr, "Requires PNG support, gd was compiled without it\n"); - return 0; -#else char *error; #ifdef HAVE_LIBJPEG FILE *in = 0; @@ -64,6 +60,5 @@ int main(void) gdImagePng(im, out); fclose(out); gdImageDestroy(im); -#endif /* HAVE_LIBPNG */ return 0; } diff --git a/src/gd2topng.c b/src/gd2topng.c index 6c0626f..fc8282f 100644 --- a/src/gd2topng.c +++ b/src/gd2topng.c @@ -52,11 +52,7 @@ main (int argc, char **argv) gdImageDestroy (im); exit (1); } -#ifdef HAVE_LIBPNG gdImagePng (im, out); -#else - fprintf(stderr, "No PNG library support available.\n"); -#endif fclose (out); gdImageDestroy (im); diff --git a/src/gddemo.c b/src/gddemo.c index 28afd3c..9818e87 100644 --- a/src/gddemo.c +++ b/src/gddemo.c @@ -16,7 +16,6 @@ int main (void) { -#ifdef HAVE_LIBPNG /* Input and output files */ FILE *in; FILE *out; @@ -181,8 +180,5 @@ main (void) if (im_in) { gdImageDestroy (im_in); } -#else - fprintf(stderr, "No PNG library support.\n"); -#endif /* HAVE_LIBPNG */ return 0; } diff --git a/src/gdparttopng.c b/src/gdparttopng.c index 42d6df2..4b07d29 100644 --- a/src/gdparttopng.c +++ b/src/gdparttopng.c @@ -49,11 +49,7 @@ main (int argc, char **argv) gdImageDestroy (im); exit (1); } -#ifdef HAVE_LIBPNG gdImagePng (im, out); -#else - fprintf(stderr, "No PNG library support.\n"); -#endif fclose (out); gdImageDestroy (im); diff --git a/src/gdtest.c b/src/gdtest.c index 35d098a..cf0eff5 100644 --- a/src/gdtest.c +++ b/src/gdtest.c @@ -24,7 +24,6 @@ static int fwriteWrapper (void *context, const char *buffer, int len); int main (int argc, char **argv) { -#ifdef HAVE_LIBPNG gdImagePtr im, ref, im2, im3; FILE *in, *out; void *iptr; @@ -409,9 +408,6 @@ main (int argc, char **argv) } gdImageDestroy (im); gdImageDestroy (ref); -#else - fprintf(stderr, "No PNG library support.\n"); -#endif /* HAVE_LIBPNG */ return 0; } diff --git a/src/gdtestft.c b/src/gdtestft.c index 53945a6..7e0e7b2 100644 --- a/src/gdtestft.c +++ b/src/gdtestft.c @@ -26,13 +26,6 @@ int main (int argc, char *argv[]) { -#ifndef HAVE_LIBFREETYPE - fprintf(stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n"); - fprintf(stderr, "Install the FreeType library, including the\n"); - fprintf(stderr, "header files. Then edit the gd Makefile, type\n"); - fprintf(stderr, "make clean, and type make again.\n"); - return 1; -#else gdImagePtr im; int blue; int blueAlpha; @@ -186,5 +179,4 @@ main (int argc, char *argv[]) gdImageDestroy (im); return 0; -#endif /* HAVE_LIBFREETYPE */ } diff --git a/src/gdtopng.c b/src/gdtopng.c index d3341b4..388e3a9 100644 --- a/src/gdtopng.c +++ b/src/gdtopng.c @@ -38,11 +38,7 @@ main (int argc, char **argv) gdImageDestroy (im); exit (1); } -#ifdef HAVE_LIBPNG gdImagePng (im, out); -#else - fprintf(stderr, "No PNG library support.\n"); -#endif fclose (out); gdImageDestroy (im); diff --git a/src/pngtogd.c b/src/pngtogd.c index f00fe8f..4f9804d 100644 --- a/src/pngtogd.c +++ b/src/pngtogd.c @@ -25,11 +25,7 @@ main (int argc, char **argv) fprintf (stderr, "Input file does not exist!\n"); exit (1); } -#ifdef HAVE_LIBPNG im = gdImageCreateFromPng (in); -#else - fprintf (stderr, "No PNG library support available.\n"); -#endif fclose (in); if (!im) { fprintf (stderr, "Input is not in PNG format!\n"); diff --git a/src/pngtogd2.c b/src/pngtogd2.c index e474afb..53a81d0 100644 --- a/src/pngtogd2.c +++ b/src/pngtogd2.c @@ -30,12 +30,7 @@ main (int argc, char **argv) fprintf(stderr, "Input file does not exist!\n"); exit (1); } -#ifdef HAVE_LIBPNG im = gdImageCreateFromPng (in); -#else - im = NULL; - fprintf(stderr, "No PNG library support available.\n"); -#endif fclose (in); if (!im) { fprintf(stderr, "Input is not in PNG format!\n"); diff --git a/src/testac.c b/src/testac.c index 0d200f0..8893cdd 100644 --- a/src/testac.c +++ b/src/testac.c @@ -17,7 +17,6 @@ void testDrawing (gdImagePtr im_in, int main (int argc, char *argv[]) { -#ifdef HAVE_LIBPNG /* Input and output files */ FILE *in; @@ -55,9 +54,6 @@ main (int argc, char *argv[]) testDrawing (im_in, 2.0, 0, 1, "noblending-doublesize-palette.png"); testDrawing (im_in, 2.0, 1, 1, "blending-doublesize-palette.png"); gdImageDestroy (im_in); -#else - fprintf (stderr, "No PNG library support.\n"); -#endif return 0; } @@ -116,11 +112,7 @@ testDrawing (gdImagePtr im_in, gdImageTrueColorToPalette (im_out, 1, 256); } -#ifdef HAVE_LIBPNG gdImagePng (im_out, out); -#else - fprintf (stderr, "No PNG library support.\n"); -#endif fclose (out); gdImageDestroy (im_out); diff --git a/src/testtr.c b/src/testtr.c index 2f216cf..ed1b374 100644 --- a/src/testtr.c +++ b/src/testtr.c @@ -11,7 +11,6 @@ int main(void) { -#ifdef HAVE_LIBFREETYPE int transparent, green, black; gdImagePtr im; @@ -47,8 +46,4 @@ main(void) gdImageDestroy (im); return 0; -#else - fprintf(stderr, "Compiled without freetype support\n"); - return 0; -#endif /* HAVE_LIBFREETYPE */ }