From 0d8a440affb59bcaac52d3803c854eea7ca870be Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 10 Jun 2018 12:15:02 +0100 Subject: [PATCH] fix build with magick7 --- configure.ac | 3 +-- libvips/foreign/magick.c | 42 +++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index bfdeb908..661919e1 100644 --- a/configure.ac +++ b/configure.ac @@ -682,8 +682,7 @@ if test x"$magick6" = x"yes"; then fi if test x"$magick6" = x"yes"; then - # do we have number_scenes in image_info ... imagemagick uses this, gm - # still uses subrange + # do we have number_scenes in image_info ... imagemagick uses this save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $MAGICK_CFLAGS" AC_CHECK_MEMBER([struct _ImageInfo.number_scenes], diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index 6e3fe4ac..95799734 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -89,6 +89,22 @@ magick_inherit_exception( ExceptionInfo *exception, Image *image ) (void) image; } +void +magick_set_number_scenes( ImageInfo *image_info, int scene, int number_scenes ) +{ + /* I can't find docs for these fields, but this seems to work. + */ + char page[256]; + + image_info->scene = scene; + image_info->number_scenes = number_scenes; + + /* Some IMs must have the string version set as well. + */ + vips_snprintf( page, 256, "%d-%d", scene, scene + number_scenes ); + image_info->scenes = strdup( page ); +} + #endif /*HAVE_MAGICK7*/ #ifdef HAVE_MAGICK6 @@ -186,19 +202,6 @@ magick_inherit_exception( ExceptionInfo *exception, Image *image ) #endif /*HAVE_INHERITEXCEPTION*/ } -#endif /*HAVE_MAGICK6*/ - -#if defined(HAVE_MAGICK6) || defined(HAVE_MAGICK7) - -void -magick_set_image_option( ImageInfo *image_info, - const char *name, const char *value ) -{ -#ifdef HAVE_SETIMAGEOPTION - SetImageOption( image_info, name, value ); -#endif /*HAVE_SETIMAGEOPTION*/ -} - void magick_set_number_scenes( ImageInfo *image_info, int scene, int number_scenes ) { @@ -222,6 +225,19 @@ magick_set_number_scenes( ImageInfo *image_info, int scene, int number_scenes ) #endif } +#endif /*HAVE_MAGICK6*/ + +#if defined(HAVE_MAGICK6) || defined(HAVE_MAGICK7) + +void +magick_set_image_option( ImageInfo *image_info, + const char *name, const char *value ) +{ +#ifdef HAVE_SETIMAGEOPTION + SetImageOption( image_info, name, value ); +#endif /*HAVE_SETIMAGEOPTION*/ +} + void magick_vips_error( const char *domain, ExceptionInfo *exception ) {