From 4311fa71da38718af13fa4b5542be22ba79b737b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 17 Jan 2012 15:29:39 +0000 Subject: [PATCH] fix the magick loader see http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=20017 --- TODO | 33 --------------------------------- libvips/foreign/magick2vips.c | 8 +++++++- libvips/foreign/magickload.c | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/TODO b/TODO index b8bebbc2..ed19115d 100644 --- a/TODO +++ b/TODO @@ -6,22 +6,6 @@ -- why is the cache operation only? it'd be useful to cache things like - interpolate as well, wouldn't it? - - - - -- perhaps Xsize and Ysize should become gint64 - - eg. easy to make an image that's 3gb and has xsize == 1 ... death! - - also bands I guess - - now everything that iterates over a dimension must be gint64 too - - - - Vips.Image has members like chain, __subclasshook__ etc etc, are we really subclassing it correctly? @@ -48,23 +32,6 @@ -- magickload is broken - - $ vips magickload healthygirl.jpg x.v - VipsRegion: inappropriate region type - VipsRegion: inappropriate region type - VipsImage: file has been truncated - - seems to be a magick bug: ping jpg reports 1 band, load jpg reports 3 band - - posted a question, wait for reply ... useless - - look at what PingImage() actually does for jpg images - - - - - - how about vips max add[babe.jpg,babe2.jpg] diff --git a/libvips/foreign/magick2vips.c b/libvips/foreign/magick2vips.c index 0bd6c0d6..90d4530a 100644 --- a/libvips/foreign/magick2vips.c +++ b/libvips/foreign/magick2vips.c @@ -67,8 +67,8 @@ */ /* Turn on debugging output. - */ #define DEBUG + */ #ifdef HAVE_CONFIG_H #include @@ -676,6 +676,12 @@ vips__magick_read( const char *filename, VipsImage *out ) return( 0 ); } +/* This has severe issues. See: + * + * http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=20017 + * + * Don't use. + */ int vips__magick_read_header( const char *filename, VipsImage *im ) { diff --git a/libvips/foreign/magickload.c b/libvips/foreign/magickload.c index 940b2afd..3fd431e1 100644 --- a/libvips/foreign/magickload.c +++ b/libvips/foreign/magickload.c @@ -2,6 +2,8 @@ * * 5/12/11 * - from openslideload.c + * 17/1/12 + * - remove header-only loads */ /* @@ -95,6 +97,11 @@ vips_foreign_load_magick_get_flags( VipsForeignLoad *load ) magick->filename ) ); } +/* + * Unfortunately, libMagick does not support header-only reads very well. See + * + * http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=20017 + * static int vips_foreign_load_magick_header( VipsForeignLoad *load ) { @@ -105,13 +112,14 @@ vips_foreign_load_magick_header( VipsForeignLoad *load ) return( 0 ); } + */ static int vips_foreign_load_magick_load( VipsForeignLoad *load ) { VipsForeignLoadMagick *magick = (VipsForeignLoadMagick *) load; - if( vips__magick_read( magick->filename, load->real ) ) + if( vips__magick_read( magick->filename, load->out ) ) return( -1 ); return( 0 ); @@ -132,7 +140,7 @@ vips_foreign_load_magick_class_init( VipsForeignLoadMagickClass *class ) object_class->description = _( "load file with ImageMagick" ); /* We need to be well to the back of the queue since the vips's - * dedicated loaders are usually preferable, if possible. + * dedicated loaders are usually preferable. */ foreign_class->priority = -100; @@ -140,8 +148,13 @@ vips_foreign_load_magick_class_init( VipsForeignLoadMagickClass *class ) load_class->get_flags_filename = vips_foreign_load_magick_get_flags_filename; load_class->get_flags = vips_foreign_load_magick_get_flags; + load_class->header = vips_foreign_load_magick_load; + + /* See comment above. + * load_class->header = vips_foreign_load_magick_header; load_class->load = vips_foreign_load_magick_load; + */ VIPS_ARG_STRING( class, "filename", 1, _( "Filename" ),