From a8fa211e51d379941a95f33c2811d07ccc4bd624 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Feb 2008 12:27:39 +0000 Subject: [PATCH] stuff --- configure.in | 10 ++++++---- libsrc/conversion/im_magick2vips.c | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index 1c41a3fd..6a53a963 100644 --- a/configure.in +++ b/configure.in @@ -196,12 +196,14 @@ if test x"$with_magick" != "xno"; then fi if test x"$with_magick" != "xno"; then - # we need ResetImageAttributeIterator() / GetNextImageAttribute() to get - # attrs, but that's 6.2+ I think ... test for them + # we need ResetImageAttributeIterator() / GetNextImageAttribute() to loop + # over attrs, but that's 6.2+ I think ... test for them + # graphicsmagick only has GetImageAttribute(), test for that as a fallback save_LIBS=$LIBS LIBS="$LIBS $MAGICK_LIBS" - AC_CHECK_FUNCS(GetNextImageAttribute, - AC_DEFINE(HAVE_MAGICK_ATTR,1,[define if your magick has attribute support.])) + AC_CHECK_FUNCS(GetNextImageAttribute GetImageAttribute, + AC_DEFINE(HAVE_MAGICK_ATTR,1, + [define if your magick has attribute support.])) LIBS=$save_LIBS fi diff --git a/libsrc/conversion/im_magick2vips.c b/libsrc/conversion/im_magick2vips.c index bdd6054e..feda6c01 100644 --- a/libsrc/conversion/im_magick2vips.c +++ b/libsrc/conversion/im_magick2vips.c @@ -16,9 +16,10 @@ * - set RGB16/GREY16 if appropriate * 10/8/07 * - support 32/64 bit imagemagick too - * 21/2/08 Bob Friesenhahn - * - use MaxRGB if QuantumRange is missing + * 21/2/08 + * - use MaxRGB if QuantumRange is missing (thanks Bob) * - look for MAGICKCORE_HDRI_SUPPORT (thanks Marcel) + * - use image->attributes if GetNextImageAttribute() is missing */ /* @@ -226,9 +227,9 @@ parse_header( Read *read ) IMAGE *im = read->im; Image *image = read->image; -#ifdef HAVE_GETNEXTIMAGEATTRIBUTE +#ifdef HAVE_MAGICK_ATTR const ImageAttribute *attr; -#endif /*HAVE_GETNEXTIMAGEATTRIBUTE*/ +#endif /*HAVE_MAGICK_ATTR*/ Image *p; int i; @@ -328,11 +329,21 @@ parse_header( Read *read ) */ im->Coding = IM_CODING_NONE; +#ifdef HAVE_MAGICK_ATTR #ifdef HAVE_GETNEXTIMAGEATTRIBUTE /* Gah, magick6.something and later only. Attach any attributes. */ ResetImageAttributeIterator( image ); while( (attr = GetNextImageAttribute( image )) ) { +#elif defined(HAVE_GETIMAGEATTRIBUTE) + /* GraphicsMagick is missing the iterator: we have to loop ourselves. + * ->attributes is marked as private in the header, but there's no + * getter so we have to access it directly. + */ + for( attr = image->attributes; attr; attr = attr->next ) { +#else /*stuff*/ + #error attributes enabled, but no access funcs found +#endif char name_text[256]; VBuf name; @@ -345,7 +356,7 @@ parse_header( Read *read ) attr->key, attr->value ); #endif /*DEBUG*/ } -#endif /*HAVE_GETNEXTIMAGEATTRIBUTE*/ +#endif /*HAVE_MAGICK_ATTR*/ /* Do we have a set of equal-sized frames? Append them.