don't use Ping in magickload

it's too unreliable :-( we are forced to read every time
This commit is contained in:
John Cupitt 2018-05-29 17:20:46 +01:00
parent d251b37d92
commit 0486218ff5
5 changed files with 14 additions and 47 deletions

View File

@ -22,7 +22,6 @@
- add fontfile option to vips_text() [fangqiao] - add fontfile option to vips_text() [fangqiao]
- add vips_transpose3d() -- swap major dimensions in a volumetric image - add vips_transpose3d() -- swap major dimensions in a volumetric image
- remove vips7 stuff from default API ... you must now #include it explicitly - remove vips7 stuff from default API ... you must now #include it explicitly
- acquire an image colormap if none set [jtorresfabra]
- added vips_argument_get_id() to fix derived classes on win32 [angelmixu] - added vips_argument_get_id() to fix derived classes on win32 [angelmixu]
12/3/18 started 8.6.4 12/3/18 started 8.6.4

View File

@ -704,17 +704,6 @@ if test x"$magick6" = x"yes"; then
LIBS="$save_LIBS" LIBS="$save_LIBS"
fi fi
if test x"$magick6" = x"yes"; then
# more recent magick6s have AcquireImageColormap rather than
# AllocateImageColormap groan
save_LIBS="$LIBS"
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(AcquireImageColormap,
AC_DEFINE(HAVE_ACQUIREIMAGECOLORMAP,1,
[define if your magick has AcquireImageColormap.]))
LIBS="$save_LIBS"
fi
if test x"$magick6" = x"yes"; then if test x"$magick6" = x"yes"; then
# more recent magick6s have SetImageExtent # more recent magick6s have SetImageExtent
save_LIBS="$LIBS" save_LIBS="$LIBS"

View File

@ -52,12 +52,6 @@ magick_acquire_image( const ImageInfo *image_info, ExceptionInfo *exception )
return( AcquireImage( image_info, exception ) ); return( AcquireImage( image_info, exception ) );
} }
void
magick_acquire_image_colormap( Image *image, int colors )
{
AcquireImageColormap( image, colors )
}
void void
magick_acquire_next_image( const ImageInfo *image_info, Image *image, magick_acquire_next_image( const ImageInfo *image_info, Image *image,
ExceptionInfo *exception ) ExceptionInfo *exception )
@ -113,16 +107,6 @@ magick_acquire_image( const ImageInfo *image_info, ExceptionInfo *exception )
#endif #endif
} }
void
magick_acquire_image_colormap( Image *image, int colors )
{
#ifdef HAVE_ACQUIREIMAGECOLORMAP
AcquireImageColormap( image, colors );
#else /*!HAVE_ACQUIREIMAGECOLORMAP*/
AllocateImageColormap( image, colors );
#endif /*HAVE_ACQUIREIMAGECOLORMAP*/
}
void void
magick_acquire_next_image( const ImageInfo *image_info, Image *image, magick_acquire_next_image( const ImageInfo *image_info, Image *image,
ExceptionInfo *exception ) ExceptionInfo *exception )

View File

@ -44,7 +44,6 @@
Image *magick_acquire_image( const ImageInfo *image_info, Image *magick_acquire_image( const ImageInfo *image_info,
ExceptionInfo *exception ); ExceptionInfo *exception );
void magick_acquire_image_colormap( Image *image, int colors );
void magick_acquire_next_image( const ImageInfo *image_info, void magick_acquire_next_image( const ImageInfo *image_info,
Image *image, ExceptionInfo *exception ); Image *image, ExceptionInfo *exception );
int magick_set_image_size( Image *image, int magick_set_image_size( Image *image,

View File

@ -58,7 +58,7 @@
* 24/4/18 * 24/4/18
* - add format hint * - add format hint
* 25/5/18 * 25/5/18
* - acquire an image colormap if none set * - don't use Ping, it's too unreliable
*/ */
/* /*
@ -329,15 +329,6 @@ parse_header( Read *read )
if( (im->Bands = get_bands( image )) < 0 ) if( (im->Bands = get_bands( image )) < 0 )
return( -1 ); return( -1 );
/* Some ImageMagick loaders (eg. TGA) fail to set the ->colormap
* field on Ping. GetImageChannelDepth() needs this and
* will crash if it's not set.
*
* If there's no colormap, set an empty one.
*/
if( !image->colormap )
magick_acquire_image_colormap( image, image->colors );
/* Depth can be 'fractional'. /* Depth can be 'fractional'.
* *
* You'd think we should use * You'd think we should use
@ -786,10 +777,6 @@ vips__magick_read( const char *filename,
return( 0 ); return( 0 );
} }
/* This has severe issues. See:
*
* http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=20017
*/
int int
vips__magick_read_header( const char *filename, vips__magick_read_header( const char *filename,
VipsImage *out, const char *format, const char *density, VipsImage *out, const char *format, const char *density,
@ -805,14 +792,18 @@ vips__magick_read_header( const char *filename,
return( -1 ); return( -1 );
#ifdef DEBUG #ifdef DEBUG
printf( "vips__magick_read_header: pinging image ...\n" ); printf( "vips__magick_read_header: reading image ...\n" );
#endif /*DEBUG*/ #endif /*DEBUG*/
read->image = PingImage( read->image_info, &read->exception ); /* It would be great if we could PingImage and just read the header,
* but sadly many IM coders do not support ping. The critical one for
* us is DICOM. TGA also has issues.
*/
read->image = ReadImage( read->image_info, &read->exception );
if( !read->image ) { if( !read->image ) {
magick_vips_error( "magick2vips", &read->exception ); magick_vips_error( "magick2vips", &read->exception );
vips_error( "magick2vips", vips_error( "magick2vips",
_( "unable to ping file \"%s\"" ), filename ); _( "unable to read file \"%s\"" ), filename );
return( -1 ); return( -1 );
} }
@ -885,7 +876,12 @@ vips__magick_read_buffer_header( const void *buf, const size_t len,
printf( "vips__magick_read_buffer_header: pinging blob ...\n" ); printf( "vips__magick_read_buffer_header: pinging blob ...\n" );
#endif /*DEBUG*/ #endif /*DEBUG*/
read->image = PingBlob( read->image_info, buf, len, &read->exception ); /* It would be great if we could PingBlob and just read the header,
* but sadly many IM coders do not support ping well. The critical one
* for us is DICOM. TGA also has issues.
*/
read->image = BlobToImage( read->image_info,
buf, len, &read->exception );
if( !read->image ) { if( !read->image ) {
magick_vips_error( "magick2vips", &read->exception ); magick_vips_error( "magick2vips", &read->exception );
vips_error( "magick2vips", "%s", _( "unable to ping blob" ) ); vips_error( "magick2vips", "%s", _( "unable to ping blob" ) );