diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index ba149d15..3dd8d073 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -22,7 +22,9 @@ add_library(zint SHARED ${zint_SRCS}) set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}" VERSION ${ZINT_VERSION}) -target_link_libraries(zint ${PNG_LIBRARIES} ) +if(PNG_FOUND) + target_link_libraries(zint ${PNG_LIBRARIES} ) +endif(PNG_FOUND) target_link_libraries(zint -lm) install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/backend/library.c b/backend/library.c index ec044180..62d594e0 100644 --- a/backend/library.c +++ b/backend/library.c @@ -781,7 +781,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt } if (strcmp(symbol->outfile, "") == 0) { +#ifdef NO_PNG + strcpy(symbol->outfile, "out.gif"); +#else strcpy(symbol->outfile, "out.png"); +#endif } #ifndef _MSC_VER unsigned char local_source[length + 1]; @@ -1085,6 +1089,11 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) { return ZINT_ERROR_INVALID_OPTION; } + if (error_number == ZINT_ERROR_INVALID_OPTION) { + /* If libpng is not installed */ + strcpy(symbol->errtxt, "Unknown output format"); + } + error_tag(symbol->errtxt, error_number); return error_number; } diff --git a/backend/raster.c b/backend/raster.c index 51f7b829..d13c1c5a 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -927,7 +927,6 @@ int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type) { #ifdef NO_PNG if (file_type == OUT_PNG_FILE) { - printf("libpng not found"); return ZINT_ERROR_INVALID_OPTION; } #endif /* NO_PNG */