From 23eaf93867cf73de691a9b68611d01664f30e8bd Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 18 Apr 2016 15:21:11 +0100 Subject: [PATCH] fix build with graphicsmagick GM is still using the old page interface of subimage/subrange, IM has deprecated that in favour of scene/number_scenes we were accidentally just supporting the new IM system ... this change adds support for GM as well, plus a configure test to pick one see https://github.com/jcupitt/libvips/issues/423 --- ChangeLog | 1 + configure.ac | 13 +++++++++++++ libvips/foreign/magick2vips.c | 18 ++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ad08c9a..cd1c9112 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - rename vips wrapper script, it was still vips-8.2, thanks Benjamin - export C++ operator overloads for MSVC linking [Lovell] - insist on giflib4 +- fix magickload @page with GraphicsMagick 29/1/16 started 8.3 - add vips_reduce*() ... a fast path for affine downsize diff --git a/configure.ac b/configure.ac index bc3ec0fc..afd5f078 100644 --- a/configure.ac +++ b/configure.ac @@ -488,6 +488,19 @@ if test x"$with_magick" != "xno"; then LIBS=$save_LIBS fi +if test x"$with_magick" != "xno"; then + # do we have number_scenes in image_info ... imagemagick uses this, gm + # still uses subrange + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $MAGICK_CFLAGS" + AC_CHECK_MEMBER([struct _ImageInfo.number_scenes], + AC_DEFINE(HAVE_NUMBER_SCENES,1, + [define if your magick has ImageInfo.number_scenes.]), + [], + [#include ]) + CFLAGS=$save_CFLAGS +fi + # orc AC_ARG_WITH([orc], AS_HELP_STRING([--without-orc], [build without orc (default: test)])) diff --git a/libvips/foreign/magick2vips.c b/libvips/foreign/magick2vips.c index ae3d4e5f..288cbf51 100644 --- a/libvips/foreign/magick2vips.c +++ b/libvips/foreign/magick2vips.c @@ -49,6 +49,8 @@ * fd during file read, handy for large numbers of input images * 14/2/16 * - add @page option, 0 by default + * 18/4/16 + * - fix @page with graphicsmagick */ /* @@ -217,16 +219,24 @@ read_new( const char *filename, VipsImage *im, #endif /*HAVE_SETIMAGEOPTION*/ if( !all_frames ) { +#ifdef HAVE_NUMBER_SCENES + /* I can't find docs for these fields, but this seems to work. + */ char page[256]; - /* Just pick a specific page. - * - * I can't find docs for these fields, but this seems to work. - */ read->image_info->scene = read->page; read->image_info->number_scenes = 1; + + /* Some IMs must have the string version set as well. + */ vips_snprintf( page, 256, "%d", read->page ); read->image_info->scenes = strdup( page ); +#else /*!HAVE_NUMBER_SCENES*/ + /* This works with GM 1.2.31 and probably others. + */ + read->image_info->subimage = read->page; + read->image_info->subrange = 1; +#endif } #ifdef DEBUG