From cedb04f0ec52115444e4111b6bca219b5a2a129a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 3 Aug 2009 13:17:03 +0000 Subject: [PATCH] stuff --- ChangeLog | 2 ++ TODO | 5 ++++- configure.in | 11 +++++++++++ libsrc/format/im_magick2vips.c | 4 ++++ src/iofuncs/header.c | 17 +++++++++++++---- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 053c9f1e..a93f8c19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ (thank you Ole) - im_buildlut() could segv for non-zero based tables (thanks Jack) - VIPS_BUF_STATIC() does not take length arg +- check for SetImageOption() so we work with GraphicsMagick too +- "header" sets a non-zero exit code if anything failed - add and use im_check_uncoded() and friends 25/3/09 started 7.18.0 diff --git a/TODO b/TODO index a153994c..a4da98eb 100644 --- a/TODO +++ b/TODO @@ -23,7 +23,10 @@ reached im_expntra() in arith -- 1-bit PNG readis broken? + + + +- 1-bit PNG read is broken? > The bug is that 1bit depth PNG addresses are incorrectly interpreted. At > least the greyscale ones. I don't recall whether indexed 1 bit works. You diff --git a/configure.in b/configure.in index 0a4c298a..72841f2f 100644 --- a/configure.in +++ b/configure.in @@ -263,6 +263,17 @@ if test x"$with_magick" != "xno"; then LIBS=$save_LIBS fi +if test x"$with_magick" != "xno"; then + # we SetImageOption to disable some DICOM read processing, but that's only + # in more recent imagemagicks and not in graphicsmagick + save_LIBS=$LIBS + LIBS="$LIBS $MAGICK_LIBS" + AC_CHECK_FUNCS(SetImageOption, + AC_DEFINE(HAVE_SETIMAGEOPTION,1, + [define if your magick has SetImageOption.])) + LIBS=$save_LIBS +fi + # liboil AC_ARG_WITH([liboil], AS_HELP_STRING([--without-liboil], [build without liboil (default: test)])) diff --git a/libsrc/format/im_magick2vips.c b/libsrc/format/im_magick2vips.c index 3d2df9ba..5df95083 100644 --- a/libsrc/format/im_magick2vips.c +++ b/libsrc/format/im_magick2vips.c @@ -29,6 +29,8 @@ * alpha channels * 12/5/09 * - fix signed/unsigned warnings + * 23/7/09 + * - SetImageOption() is optional (to help GM) */ /* @@ -593,6 +595,7 @@ im_magick2vips( const char *filename, IMAGE *im ) if( !(read = read_new( filename, im )) ) return( -1 ); +#ifdef HAVE_SETIMAGEOPTION /* When reading DICOM images, we want to ignore any * window_center/_width setting, since it may put pixels outside the * 0-65535 range and lose data. @@ -601,6 +604,7 @@ im_magick2vips( const char *filename, IMAGE *im ) * can interpret them if it wants. */ SetImageOption( read->image_info, "dcm:display-range", "reset" ); +#endif /*HAVE_SETIMAGEOPTION*/ read->image = ReadImage( read->image_info, &read->exception ); if( !read->image ) { diff --git a/src/iofuncs/header.c b/src/iofuncs/header.c index 27cc9168..fc320501 100644 --- a/src/iofuncs/header.c +++ b/src/iofuncs/header.c @@ -31,6 +31,8 @@ * - use im_history_get() * 29/2/08 * - don't stop on error + * 23/7/09 + * - ... but do return an error code if anything failed */ /* @@ -121,7 +123,7 @@ print_header( IMAGE *im ) if( im_header_get( im, main_option_field, &value ) ) return( -1 ); - /* Display the save form, if there is one. This was we display + /* Display the save form, if there is one. This way we display * something useful for ICC profiles, xml fields, etc. */ type = G_VALUE_TYPE( &value ); @@ -154,6 +156,7 @@ main( int argc, char *argv[] ) GOptionContext *context; GError *error = NULL; int i; + int result; if( im_init_world( argv[0] ) ) error_exit( "unable to start VIPS" ); @@ -175,18 +178,24 @@ main( int argc, char *argv[] ) g_option_context_free( context ); + result = 0; + for( i = 1; i < argc; i++ ) { IMAGE *im; - if( !(im = im_open( argv[i], "r" )) ) + if( !(im = im_open( argv[i], "r" )) ) { print_error( "%s: unable to open", argv[i] ); + result = 1; + } - if( im && print_header( im ) ) + if( im && print_header( im ) ) { print_error( "%s: unable to print header", argv[i] ); + result = 1; + } if( im ) im_close( im ); } - return( 0 ); + return( result ); }