From b32db0dcfb5376fa0259a9a4a7e91339a78f6850 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 13 Mar 2018 21:35:39 +0800 Subject: [PATCH] FS-11022 #resolve ImageMagic 7 support --- configure.ac | 4 ++++ src/mod/formats/mod_imagick/Makefile.am | 5 +++++ src/mod/formats/mod_imagick/mod_imagick.c | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b8df6d1759..a52af80ccd 100644 --- a/configure.ac +++ b/configure.ac @@ -1389,6 +1389,10 @@ PKG_CHECK_MODULES([MAGICK], [ImageMagick >= 6.0.0],[ AM_CONDITIONAL([HAVE_MAGICK],[true])],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MAGICK],[false])]) +PKG_CHECK_MODULES([MAGICK7], [ImageMagick >= 7.0.0],[ + AM_CONDITIONAL([HAVE_MAGICK7],[true])],[ + AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MAGICK7],[false])]) + PKG_CHECK_MODULES([SILK], [silk >= 1.0.8],[ AM_CONDITIONAL([HAVE_SILK],[true])],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SILK],[false])]) diff --git a/src/mod/formats/mod_imagick/Makefile.am b/src/mod/formats/mod_imagick/Makefile.am index 19270b6003..3bcc4017c1 100644 --- a/src/mod/formats/mod_imagick/Makefile.am +++ b/src/mod/formats/mod_imagick/Makefile.am @@ -6,6 +6,11 @@ if HAVE_MAGICK mod_LTLIBRARIES = mod_imagick.la mod_imagick_la_SOURCES = mod_imagick.c mod_imagick_la_CFLAGS = $(AM_CFLAGS) $(MAGICK_CFLAGS) + +if HAVE_MAGICK7 +mod_imagick_la_CFLAGS += -DHAVE_MAGIC7 +endif + mod_imagick_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(MAGICK_LIBS) mod_imagick_la_LDFLAGS = -avoid-version -module -no-undefined -shared diff --git a/src/mod/formats/mod_imagick/mod_imagick.c b/src/mod/formats/mod_imagick/mod_imagick.c index 96efd74df0..d008632b74 100644 --- a/src/mod/formats/mod_imagick/mod_imagick.c +++ b/src/mod/formats/mod_imagick/mod_imagick.c @@ -49,8 +49,11 @@ #define MAGICKCORE_HDRI_ENABLE 0 #endif +#ifdef HAVE_MAGIC7 +#include +#else #include - +#endif #ifdef _MSC_VER // Disable MSVC warnings that suggest making code non-portable. @@ -101,7 +104,13 @@ static void *SWITCH_THREAD_FUNC open_pdf_thread_run(switch_thread_t *thread, voi Image *tmp_images; switch_snprintf(path, sizeof(path), "%s[%d]", context->path, pagenumber); switch_set_string(context->image_info->filename, path); + +#ifdef HAVE_MAGIC7 + if ((tmp_images = ReadImages(context->image_info, path, context->exception))) { +#else if ((tmp_images = ReadImages(context->image_info, context->exception))) { +#endif + pagenumber++; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s page %d loaded\n", context->path, pagenumber); AppendImageToList(&context->images, tmp_images); @@ -229,7 +238,12 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha switch_set_string(context->image_info->filename, path); } +#ifdef HAVE_MAGIC7 + context->images = ReadImages(context->image_info, context->lazy ? range_path : path, context->exception); +#else context->images = ReadImages(context->image_info, context->exception); +#endif + if (context->exception->severity != UndefinedException) { CatchException(context->exception); }