FS-11022 #resolve ImageMagic 7 support

This commit is contained in:
Seven Du 2018-03-13 21:35:39 +08:00 committed by Muteesa Fred
parent d7fb26b12a
commit b32db0dcfb
3 changed files with 24 additions and 1 deletions

View File

@ -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])])

View File

@ -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

View File

@ -49,8 +49,11 @@
#define MAGICKCORE_HDRI_ENABLE 0
#endif
#ifdef HAVE_MAGIC7
#include <MagickCore/MagickCore.h>
#else
#include <magick/MagickCore.h>
#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);
}