Merge branch 'master' into add-icc-fallbacks

This commit is contained in:
John Cupitt 2019-01-10 15:48:37 +00:00
commit 960324b08a
7 changed files with 87 additions and 21 deletions

View File

@ -16,10 +16,14 @@
- add vips_CMYK2XYZ() and vips_XYZ2CMYK(), plus associated routes - add vips_CMYK2XYZ() and vips_XYZ2CMYK(), plus associated routes
- include cmyk and srgb fallback profiles - include cmyk and srgb fallback profiles
4/1/19 started 8.7.4
- fix memory leak in magickload [kleisauke]
21/11/18 started 8.7.3 21/11/18 started 8.7.3
- fix infinite loop for autofit with non-scaleable font - fix infinite loop for autofit with non-scaleable font
- mapim was not offsetting by window offset [erdmann] - mapim was not offsetting by window offset [erdmann]
- better rounding for scale [kleisauke] - better rounding for scale [kleisauke]
- fix a memleak in magick6load [kleisauke]
21/11/18 started 8.7.2 21/11/18 started 8.7.2
- more info output for temp files to help diagnose problems - more info output for temp files to help diagnose problems

View File

@ -762,6 +762,16 @@ if test x"$magick6" = x"yes"; then
LIBS="$save_LIBS" LIBS="$save_LIBS"
fi fi
if test x"$magick6" = x"yes"; then
# GM is missing AcquireExceptionInfo
save_LIBS="$LIBS"
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(AcquireExceptionInfo,
AC_DEFINE(HAVE_ACQUIREEXCEPTIONINFO,1,
[define if your magick has AcquireExceptionInfo.]))
LIBS="$save_LIBS"
fi
# have flags to turn load and save off independently ... some people will want # have flags to turn load and save off independently ... some people will want
# save but not load, for example # save but not load, for example
AC_ARG_ENABLE([magickload], AC_ARG_ENABLE([magickload],

View File

@ -85,6 +85,18 @@ magick_set_property( Image *image, const char *property, const char *value,
(void) SetImageProperty( image, property, value, exception ); (void) SetImageProperty( image, property, value, exception );
} }
ExceptionInfo *
magick_acquire_exception( void )
{
return( AcquireExceptionInfo() );
}
void
magick_destroy_exception( ExceptionInfo *exception )
{
VIPS_FREEF( DestroyExceptionInfo, exception );
}
void void
magick_inherit_exception( ExceptionInfo *exception, Image *image ) magick_inherit_exception( ExceptionInfo *exception, Image *image )
{ {
@ -197,6 +209,42 @@ magick_set_property( Image *image, const char *property, const char *value,
#endif /*HAVE_SETIMAGEPROPERTY*/ #endif /*HAVE_SETIMAGEPROPERTY*/
} }
ExceptionInfo *
magick_acquire_exception( void )
{
ExceptionInfo *exception;
#ifdef HAVE_ACQUIREEXCEPTIONINFO
/* IM6+
*/
exception = AcquireExceptionInfo();
#else /*!HAVE_ACQUIREEXCEPTIONINFO*/
/* gm
*/
exception = g_new( ExceptionInfo, 1 );
GetExceptionInfo( exception );
#endif /*HAVE_ACQUIREEXCEPTIONINFO*/
return( exception );
}
void
magick_destroy_exception( ExceptionInfo *exception )
{
#ifdef HAVE_ACQUIREEXCEPTIONINFO
/* IM6+ will free the exception in destroy.
*/
VIPS_FREEF( DestroyExceptionInfo, exception );
#else /*!HAVE_ACQUIREEXCEPTIONINFO*/
/* gm and very old IM need to free the memory too.
*/
if( exception ) {
DestroyExceptionInfo( exception );
g_free( exception );
}
#endif /*HAVE_ACQUIREEXCEPTIONINFO*/
}
void void
magick_inherit_exception( ExceptionInfo *exception, Image *image ) magick_inherit_exception( ExceptionInfo *exception, Image *image )
{ {

View File

@ -58,7 +58,10 @@ void magick_set_image_option( ImageInfo *image_info,
void magick_set_number_scenes( ImageInfo *image_info, void magick_set_number_scenes( ImageInfo *image_info,
int scene, int number_scenes ); int scene, int number_scenes );
ExceptionInfo *magick_acquire_exception( void );
void magick_destroy_exception( ExceptionInfo *exception );
void magick_inherit_exception( ExceptionInfo *exception, Image *image ); void magick_inherit_exception( ExceptionInfo *exception, Image *image );
void magick_sniff_bytes( ImageInfo *image_info, void magick_sniff_bytes( ImageInfo *image_info,
const unsigned char *bytes, size_t length ); const unsigned char *bytes, size_t length );
void magick_sniff_file( ImageInfo *image_info, const char *filename ); void magick_sniff_file( ImageInfo *image_info, const char *filename );

View File

@ -59,6 +59,9 @@
* - don't use Ping, it's too unreliable * - don't use Ping, it's too unreliable
* 24/7/18 * 24/7/18
* - sniff extra filetypes * - sniff extra filetypes
* 4/1/19 kleisauke
* - we did not chain exceptions correctly, causing a memory leak
* - added wrapper funcs for exception handling
*/ */
/* /*
@ -137,7 +140,7 @@ typedef struct _Read {
Image *image; Image *image;
ImageInfo *image_info; ImageInfo *image_info;
ExceptionInfo exception; ExceptionInfo *exception;
/* Number of pages in image. /* Number of pages in image.
*/ */
@ -168,9 +171,7 @@ read_free( Read *read )
VIPS_FREEF( DestroyImageList, read->image ); VIPS_FREEF( DestroyImageList, read->image );
VIPS_FREEF( DestroyImageInfo, read->image_info ); VIPS_FREEF( DestroyImageInfo, read->image_info );
VIPS_FREE( read->frames ); VIPS_FREE( read->frames );
if ( (&read->exception)->signature == MagickSignature ) { VIPS_FREEF( magick_destroy_exception, read->exception );
DestroyExceptionInfo( &read->exception );
}
VIPS_FREEF( vips_g_mutex_free, read->lock ); VIPS_FREEF( vips_g_mutex_free, read->lock );
} }
@ -209,7 +210,7 @@ read_new( const char *filename, VipsImage *im,
read->im = im; read->im = im;
read->image = NULL; read->image = NULL;
read->image_info = CloneImageInfo( NULL ); read->image_info = CloneImageInfo( NULL );
GetExceptionInfo( &read->exception ); read->exception = magick_acquire_exception();
read->n_pages = 0; read->n_pages = 0;
read->n_frames = 0; read->n_frames = 0;
read->frames = NULL; read->frames = NULL;
@ -765,9 +766,9 @@ vips__magick_read( const char *filename,
printf( "magick2vips: calling ReadImage() ...\n" ); printf( "magick2vips: calling ReadImage() ...\n" );
#endif /*DEBUG*/ #endif /*DEBUG*/
read->image = ReadImage( read->image_info, &read->exception ); 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 read file \"%s\"" ), filename ); _( "unable to read file \"%s\"" ), filename );
return( -1 ); return( -1 );
@ -803,9 +804,9 @@ vips__magick_read_header( const char *filename,
* but sadly many IM coders do not support ping. The critical one for * but sadly many IM coders do not support ping. The critical one for
* us is DICOM. TGA also has issues. * us is DICOM. TGA also has issues.
*/ */
read->image = ReadImage( read->image_info, &read->exception ); 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 read file \"%s\"" ), filename ); _( "unable to read file \"%s\"" ), filename );
return( -1 ); return( -1 );
@ -845,9 +846,9 @@ vips__magick_read_buffer( const void *buf, const size_t len,
#endif /*DEBUG*/ #endif /*DEBUG*/
read->image = BlobToImage( read->image_info, read->image = BlobToImage( read->image_info,
buf, len, &read->exception ); 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 read buffer" ) ); vips_error( "magick2vips", "%s", _( "unable to read buffer" ) );
return( -1 ); return( -1 );
} }
@ -883,9 +884,9 @@ vips__magick_read_buffer_header( const void *buf, const size_t len,
* for us is DICOM. TGA also has issues. * for us is DICOM. TGA also has issues.
*/ */
read->image = BlobToImage( read->image_info, read->image = BlobToImage( read->image_info,
buf, len, &read->exception ); 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" ) );
return( -1 ); return( -1 );
} }

View File

@ -279,7 +279,7 @@ vips_foreign_load_magick7_dispose( GObject *gobject )
VIPS_FREEF( DestroyImageInfo, magick7->image_info ); VIPS_FREEF( DestroyImageInfo, magick7->image_info );
VIPS_FREE( magick7->frames ); VIPS_FREE( magick7->frames );
VIPS_FREE( magick7->cache_view ); VIPS_FREE( magick7->cache_view );
VIPS_FREEF( DestroyExceptionInfo, magick7->exception ); VIPS_FREEF( magick_destroy_exception, magick7->exception );
VIPS_FREEF( vips_g_mutex_free, magick7->lock ); VIPS_FREEF( vips_g_mutex_free, magick7->lock );
G_OBJECT_CLASS( vips_foreign_load_magick7_parent_class )-> G_OBJECT_CLASS( vips_foreign_load_magick7_parent_class )->
@ -298,7 +298,7 @@ vips_foreign_load_magick7_build( VipsObject *object )
magick_genesis(); magick_genesis();
magick7->image_info = CloneImageInfo( NULL ); magick7->image_info = CloneImageInfo( NULL );
magick7->exception = AcquireExceptionInfo(); magick7->exception = magick_acquire_exception();
magick7->lock = vips_g_mutex_new(); magick7->lock = vips_g_mutex_new();
if( !magick7->image_info ) if( !magick7->image_info )
@ -760,14 +760,14 @@ ismagick7( const char *filename )
/* Horribly slow :-( /* Horribly slow :-(
*/ */
image_info = CloneImageInfo( NULL ); image_info = CloneImageInfo( NULL );
exception = AcquireExceptionInfo(); exception = magick_acquire_exception();
vips_strncpy( image_info->filename, filename, MagickPathExtent ); vips_strncpy( image_info->filename, filename, MagickPathExtent );
magick_sniff_file( image_info, filename ); magick_sniff_file( image_info, filename );
image = PingImage( image_info, exception ); image = PingImage( image_info, exception );
result = image != NULL; result = image != NULL;
VIPS_FREEF( DestroyImageList, image ); VIPS_FREEF( DestroyImageList, image );
VIPS_FREEF( DestroyImageInfo, image_info ); VIPS_FREEF( DestroyImageInfo, image_info );
VIPS_FREEF( DestroyExceptionInfo, exception ); VIPS_FREEF( magick_destroy_exception, exception );
return( result ); return( result );
} }
@ -863,13 +863,13 @@ vips_foreign_load_magick7_buffer_is_a_buffer( const void *buf, size_t len )
/* Horribly slow :-( /* Horribly slow :-(
*/ */
image_info = CloneImageInfo( NULL ); image_info = CloneImageInfo( NULL );
exception = AcquireExceptionInfo(); exception = magick_acquire_exception();
magick_sniff_bytes( image_info, buf, len ); magick_sniff_bytes( image_info, buf, len );
image = PingBlob( image_info, buf, len, exception ); image = PingBlob( image_info, buf, len, exception );
result = image != NULL; result = image != NULL;
VIPS_FREEF( DestroyImageList, image ); VIPS_FREEF( DestroyImageList, image );
VIPS_FREEF( DestroyImageInfo, image_info ); VIPS_FREEF( DestroyImageInfo, image_info );
VIPS_FREEF( DestroyExceptionInfo, exception ); VIPS_FREEF( magick_destroy_exception, exception );
return( result ); return( result );
} }

View File

@ -81,7 +81,7 @@ vips_foreign_save_magick_dispose( GObject *gobject )
VIPS_FREE( magick->map ); VIPS_FREE( magick->map );
VIPS_FREEF( DestroyImageList, magick->images ); VIPS_FREEF( DestroyImageList, magick->images );
VIPS_FREEF( DestroyImageInfo, magick->image_info ); VIPS_FREEF( DestroyImageInfo, magick->image_info );
VIPS_FREEF( DestroyExceptionInfo, magick->exception ); VIPS_FREEF( magick_destroy_exception, magick->exception );
G_OBJECT_CLASS( vips_foreign_save_magick_parent_class )-> G_OBJECT_CLASS( vips_foreign_save_magick_parent_class )->
dispose( gobject ); dispose( gobject );
@ -218,7 +218,7 @@ vips_foreign_save_magick_build( VipsObject *object )
*/ */
im = save->ready; im = save->ready;
magick->exception = AcquireExceptionInfo(); magick->exception = magick_acquire_exception();
magick->image_info = CloneImageInfo( NULL ); magick->image_info = CloneImageInfo( NULL );
magick->storage_type = UndefinedPixel; magick->storage_type = UndefinedPixel;