PROJECT("sane-kds-s2000w-net" VERSION "1.0.28")
+OPTION(WITHOUT_IMAGEMAGICK "without ImageMagick library" OFF)
+MESSAGE(STATUS "WITHOUT_IMAGEMAGICK: " ${WITHOUT_IMAGEMAGICK})
+
FIND_PACKAGE(Git)
IF(GIT_FOUND)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} branch --show-current
FIND_PACKAGE(JSON-C REQUIRED)
MESSAGE(STATUS "find json-c: " ${JSON\-C_DIR})
-FIND_PACKAGE(ImageMagick COMPONENTS MagickCore REQUIRED)
-MESSAGE(STATUS "find ImageMagick: " ${ImageMagick_LIBRARIES})
-MESSAGE(STATUS "ImageMagick_VERSION_STRING: " ${ImageMagick_VERSION_STRING})
-STRING(SUBSTRING ${ImageMagick_VERSION_STRING} 0 1 IMAGE_MAGICK_MAJOR)
-MESSAGE(STATUS "define IMAGE_MAGICK_MAJOR: " ${IMAGE_MAGICK_MAJOR})
-ADD_COMPILE_DEFINITIONS(IMAGE_MAGICK_MAJOR=${IMAGE_MAGICK_MAJOR})
-IF(${IMAGE_MAGICK_MAJOR} EQUAL 7)
- LIST(APPEND ImageMagick_INCLUDE_DIRS "/usr/include/x86_64-linux-gnu/ImageMagick-7")
+IF(NOT WITHOUT_IMAGEMAGICK)
+ FIND_PACKAGE(ImageMagick COMPONENTS MagickCore REQUIRED)
+ MESSAGE(STATUS "find ImageMagick: " ${ImageMagick_LIBRARIES})
+ MESSAGE(STATUS "ImageMagick_VERSION_STRING: " ${ImageMagick_VERSION_STRING})
+ STRING(SUBSTRING ${ImageMagick_VERSION_STRING} 0 1 IMAGE_MAGICK_MAJOR)
+ MESSAGE(STATUS "define IMAGE_MAGICK_MAJOR: " ${IMAGE_MAGICK_MAJOR})
+ ADD_COMPILE_DEFINITIONS(IMAGE_MAGICK_MAJOR=${IMAGE_MAGICK_MAJOR})
+ IF(${IMAGE_MAGICK_MAJOR} EQUAL 7)
+ LIST(APPEND ImageMagick_INCLUDE_DIRS "/usr/include/x86_64-linux-gnu/ImageMagick-7")
+ ENDIF()
+ MESSAGE(STATUS "ImageMagick_INCLUDE_DIRS: " ${ImageMagick_INCLUDE_DIRS})
ENDIF()
-MESSAGE(STATUS "ImageMagick_INCLUDE_DIRS: " ${ImageMagick_INCLUDE_DIRS})
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "/" CACHE PATH "install prefix" FORCE)
"kds_s2000w_handler.c"
"kds_s2000w_handler_opts.c"
"kds_s2000w_client.c"
- "kds_s2000w_image_converter.c"
"kds_s2000w_debug.c"
"kds_s2000w_config.c"
"kds_s2000w_heartbeat.c")
+IF(NOT WITHOUT_IMAGEMAGICK)
+ LIST(APPEND SOURCES "kds_s2000w_image_converter_magick.c")
+ELSE()
+ LIST(APPEND SOURCES "kds_s2000w_image_converter_netpbm.c")
+ENDIF()
+
ADD_LIBRARY("sane-kds_s2000w_net" SHARED ${SOURCES})
SET_TARGET_PROPERTIES("sane-kds_s2000w_net" PROPERTIES VERSION 1)
TARGET_INCLUDE_DIRECTORIES("sane-kds_s2000w_net"
PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR}
- ${ImageMagick_INCLUDE_DIRS})
+ ${CMAKE_CURRENT_BINARY_DIR})
TARGET_LINK_LIBRARIES("sane-kds_s2000w_net"
${MATH}
${PTHREAD}
${CONFUSE}
${CURL_LIBRARY}
- ${ImageMagick_LIBRARIES}
json-c)
+IF(NOT WITHOUT_IMAGEMAGICK)
+ TARGET_INCLUDE_DIRECTORIES("sane-kds_s2000w_net"
+ PRIVATE
+ ${ImageMagick_INCLUDE_DIRS})
+ TARGET_LINK_LIBRARIES("sane-kds_s2000w_net"
+ ${ImageMagick_LIBRARIES})
+ENDIF()
+
ADD_LIBRARY("sane-kds_s2000w_net-static"
STATIC
${SOURCES}
SET_TARGET_PROPERTIES("sane-kds_s2000w_net-static" PROPERTIES OUTPUT_NAME "sane-kds_s2000w_net")
TARGET_INCLUDE_DIRECTORIES("sane-kds_s2000w_net-static"
PRIVATE
- ${CMAKE_CURRENT_BINARY_DIR}
- ${ImageMagick_INCLUDE_DIRS})
+ ${CMAKE_CURRENT_BINARY_DIR})
TARGET_LINK_LIBRARIES("sane-kds_s2000w_net-static"
${MATH}
${PTHREAD}
${CONFUSE}
${CURL_LIBRARY}
- ${ImageMagick_LIBRARIES}
json-c)
+IF(NOT WITHOUT_IMAGEMAGICK)
+ TARGET_INCLUDE_DIRECTORIES("sane-kds_s2000w_net-static"
+ PRIVATE
+ ${ImageMagick_INCLUDE_DIRS})
+ TARGET_LINK_LIBRARIES("sane-kds_s2000w_net-static"
+ ${ImageMagick_LIBRARIES})
+ENDIF()
+
INSTALL(TARGETS "sane-kds_s2000w_net" "sane-kds_s2000w_net-static"
DESTINATION ${CMAKE_LIBRARY_PATH}/sane)
install(FILES "kds_s2000w_net.conf"
+++ /dev/null
-#define MAGICKCORE_QUANTUM_DEPTH 16
-#define MAGICKCORE_HDRI_ENABLE 0
-
-#ifndef IMAGE_MAGICK_MAJOR
-#define IMAGE_MAGICK_MAJOR 6
-#endif
-
-#if IMAGE_MAGICK_MAJOR == 6
-#include <magick/MagickCore.h>
-#endif
-#if IMAGE_MAGICK_MAJOR == 7
-#include <MagickCore/MagickCore.h>
-#endif
-#include "kds_s2000w_image_converter.h"
-#include "kds_s2000w_debug.h"
-
-void _kds_s2000w_image_converter_to_pnm_depth(blobdata* in,
- blobdata* out,
- int depth,
- const char* format)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_to_pnm_With_depth");
-
- ExceptionInfo* exception = AcquireExceptionInfo();
- ImageInfo* image_info = CloneImageInfo(NULL);
-
- sprintf(image_info->filename, "streamin.%s", format);
- kds_s2000w_debug_printf(DEBUG, image_info->filename);
-
- Image* input_image = BlobToImage(image_info, in->data, in->size , exception);
-
- if (exception->severity != UndefinedException) {
- kds_s2000w_debug_printf(ERROR, GetExceptionMessage(exception->error_number));
- CatchException(exception);
- }
-
- if (input_image == NULL) {
- DestroyImageInfo(image_info);
- DestroyExceptionInfo(exception);
- return;
- }
-
- input_image->properties = NULL;
-
- DestroyImageInfo(image_info);
- DestroyExceptionInfo(exception);
- exception = AcquireExceptionInfo();
- image_info = CloneImageInfo(NULL);
- sprintf(image_info->filename, "streamout.pnm");
-
- if (depth > -1)
-#if IMAGE_MAGICK_MAJOR == 6
- SetImageDepth(input_image, depth);
-#endif
-#if IMAGE_MAGICK_MAJOR == 7
- SetImageDepth(input_image, depth, exception);
-#endif
-
- out->data = ImageToBlob(image_info, input_image, &out->size, exception);
-
- DestroyImageInfo(image_info);
- image_info = NULL;
- DestroyImage(input_image);
- input_image = NULL;
- DestroyExceptionInfo(exception);
- exception = NULL;
-}
-
-void kds_s2000w_image_converter_metadata_from_jpg(blobdata* image, image_metadata* mdata)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_metadata_from_image");
-
- ExceptionInfo* exception = AcquireExceptionInfo();
- ImageInfo* image_info = CloneImageInfo(NULL);
- sprintf(image_info->filename, "image.pnm");
-
- Image* input_image = BlobToImage(image_info, image->data, image->size , exception);
-
- if (exception->severity != UndefinedException) {
- kds_s2000w_debug_printf(ERROR, GetExceptionMessage(exception->error_number));
- CatchException(exception);
- }
-
- mdata->width = input_image->columns;
- mdata->height = input_image->rows;
- mdata->depth = input_image->depth;
-
- DestroyImageInfo(image_info);
- image_info = NULL;
- DestroyImage(input_image);
- input_image = NULL;
- DestroyExceptionInfo(exception);
- exception = NULL;
-}
-
-void kds_s2000w_image_converter_jpg_to_pnm(blobdata* in, blobdata* out, int depth)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_jpg_to_pnm_With_depth");
-
- _kds_s2000w_image_converter_to_pnm_depth(in, out, depth, "jpg");
-}
-
-void kds_s2000w_image_converter_tiff_to_pnm(blobdata* in, blobdata* out)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_tiff_to_pnm");
-
- _kds_s2000w_image_converter_to_pnm_depth(in, out, -1, "tiff");
-}
\ No newline at end of file
--- /dev/null
+#define MAGICKCORE_QUANTUM_DEPTH 16
+#define MAGICKCORE_HDRI_ENABLE 0
+
+#ifndef IMAGE_MAGICK_MAJOR
+#define IMAGE_MAGICK_MAJOR 6
+#endif
+
+#if IMAGE_MAGICK_MAJOR == 6
+#include <magick/MagickCore.h>
+#endif
+#if IMAGE_MAGICK_MAJOR == 7
+#include <MagickCore/MagickCore.h>
+#endif
+#include "kds_s2000w_image_converter.h"
+#include "kds_s2000w_debug.h"
+
+void _kds_s2000w_image_converter_to_pnm_depth(blobdata* in,
+ blobdata* out,
+ int depth,
+ const char* format)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_to_pnm_With_depth");
+
+ ExceptionInfo* exception = AcquireExceptionInfo();
+ ImageInfo* image_info = CloneImageInfo(NULL);
+
+ sprintf(image_info->filename, "streamin.%s", format);
+ kds_s2000w_debug_printf(DEBUG, image_info->filename);
+
+ Image* input_image = BlobToImage(image_info, in->data, in->size , exception);
+
+ if (exception->severity != UndefinedException) {
+ kds_s2000w_debug_printf(ERROR, GetExceptionMessage(exception->error_number));
+ CatchException(exception);
+ }
+
+ if (input_image == NULL) {
+ DestroyImageInfo(image_info);
+ DestroyExceptionInfo(exception);
+ return;
+ }
+
+ input_image->properties = NULL;
+
+ DestroyImageInfo(image_info);
+ DestroyExceptionInfo(exception);
+ exception = AcquireExceptionInfo();
+ image_info = CloneImageInfo(NULL);
+ sprintf(image_info->filename, "streamout.pnm");
+
+ if (depth > -1)
+#if IMAGE_MAGICK_MAJOR == 6
+ SetImageDepth(input_image, depth);
+#endif
+#if IMAGE_MAGICK_MAJOR == 7
+ SetImageDepth(input_image, depth, exception);
+#endif
+
+ out->data = ImageToBlob(image_info, input_image, &out->size, exception);
+
+ DestroyImageInfo(image_info);
+ image_info = NULL;
+ DestroyImage(input_image);
+ input_image = NULL;
+ DestroyExceptionInfo(exception);
+ exception = NULL;
+}
+
+void kds_s2000w_image_converter_metadata_from_jpg(blobdata* image, image_metadata* mdata)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_metadata_from_image");
+
+ ExceptionInfo* exception = AcquireExceptionInfo();
+ ImageInfo* image_info = CloneImageInfo(NULL);
+ sprintf(image_info->filename, "image.pnm");
+
+ Image* input_image = BlobToImage(image_info, image->data, image->size , exception);
+
+ if (exception->severity != UndefinedException) {
+ kds_s2000w_debug_printf(ERROR, GetExceptionMessage(exception->error_number));
+ CatchException(exception);
+ }
+
+ mdata->width = input_image->columns;
+ mdata->height = input_image->rows;
+ mdata->depth = input_image->depth;
+
+ DestroyImageInfo(image_info);
+ image_info = NULL;
+ DestroyImage(input_image);
+ input_image = NULL;
+ DestroyExceptionInfo(exception);
+ exception = NULL;
+}
+
+void kds_s2000w_image_converter_jpg_to_pnm(blobdata* in, blobdata* out, int depth)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_jpg_to_pnm_With_depth");
+
+ _kds_s2000w_image_converter_to_pnm_depth(in, out, depth, "jpg");
+}
+
+void kds_s2000w_image_converter_tiff_to_pnm(blobdata* in, blobdata* out)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_tiff_to_pnm");
+
+ _kds_s2000w_image_converter_to_pnm_depth(in, out, -1, "tiff");
+}
\ No newline at end of file
--- /dev/null
+#include "kds_s2000w_image_converter.h"
+
+void kds_s2000w_image_converter_metadata_from_jpg(blobdata* image, image_metadata* mdata)
+{
+ return;
+}
+
+void kds_s2000w_image_converter_jpg_to_pnm(blobdata* in, blobdata* out, int depth)
+{
+ return;
+}
+
+void kds_s2000w_image_converter_tiff_to_pnm(blobdata* in, blobdata* out)
+{
+ return;
+}