diff --git a/configure.ac b/configure.ac index 3ef1c2b5..d2d97405 100644 --- a/configure.ac +++ b/configure.ac @@ -799,11 +799,13 @@ if test x"$enable_magicksave" != x"yes"; then AC_CHECK_FUNCS(ImportImagePixels,[ AC_DEFINE(HAVE_IMPORTIMAGEPIXELS,1, [define if you have ImportImagePixels.]) - ],[ - AC_MSG_WARN([ImportImagePixels not found; disabling magicksave]) - enable_magicksave=no - ] + ],[] ) + AC_CHECK_FUNCS(ImagesToBlob,[ + AC_DEFINE(HAVE_IMAGESTOBLOB,1, + [define if you have ImagesToBlob.]) + ],[] + ) LIBS="$save_LIBS" fi diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index 49a8aa7b..507614bf 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -78,6 +78,13 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, type, pixels, exception ) ); } +void * +magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, + ExceptionInfo *exception ) +{ + return( ImagesToBlob( image_info, images, length, exception ) ); +} + void magick_set_property( Image *image, const char *property, const char *value, ExceptionInfo *exception ) @@ -193,10 +200,31 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, return( ImportImagePixels( image, x, y, width, height, map, type, pixels ) ); #else /*!HAVE_IMPORTIMAGEPIXELS*/ + g_assert(image != (Image *) NULL); + g_assert(image->signature == MagickSignature); + + Image *constitute_image= + ConstituteImage(width,height,map,type,pixels,&image->exception); + if (constitute_image) { + (void) CompositeImage(image,CopyCompositeOp,constitute_image,x,y); + DestroyImage(constitute_image); + return (image->exception.severity == UndefinedException); + } return( MagickFalse ); #endif /*HAVE_IMPORTIMAGEPIXELS*/ } +void * +magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, + ExceptionInfo *exception ) +{ +#ifdef HAVE_IMAGESTOBLOB + return( ImagesToBlob( image_info, images, length, exception ) ); +#else + return( ImageToBlob( image_info, images, length, exception ) ); +#endif /*HAVE_IMAGESTOBLOB*/ +} + void magick_set_property( Image *image, const char *property, const char *value, ExceptionInfo *exception ) diff --git a/libvips/foreign/magick.h b/libvips/foreign/magick.h index 4cdb8c41..594b4c8d 100644 --- a/libvips/foreign/magick.h +++ b/libvips/foreign/magick.h @@ -51,6 +51,8 @@ int magick_set_image_size( Image *image, int magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, const size_t width, const size_t height, const char *map, const StorageType type,const void *pixels, ExceptionInfo *exception ); +void *magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, + ExceptionInfo *exception ); void magick_set_property( Image *image, const char *property, const char *value, ExceptionInfo *exception ); void magick_set_image_option( ImageInfo *image_info, diff --git a/libvips/foreign/magicksave.c b/libvips/foreign/magicksave.c index 2fc9f580..036e732c 100644 --- a/libvips/foreign/magicksave.c +++ b/libvips/foreign/magicksave.c @@ -112,7 +112,7 @@ magick_write_block( VipsRegion *region, VipsRect *area, void *a ) { VipsForeignSaveMagick *magick = (VipsForeignSaveMagick *) a; - MagickBooleanType status; + int status; void *p; p = VIPS_REGION_ADDR( region, area->left, area->top ); @@ -221,7 +221,7 @@ vips_foreign_save_magick_build( VipsObject *object ) magick->exception = magick_acquire_exception(); magick->image_info = CloneImageInfo( NULL ); - magick->storage_type = UndefinedPixel; + magick->storage_type = CharPixel; switch( im->BandFmt ) { case VIPS_FORMAT_UCHAR: magick->storage_type = CharPixel; @@ -465,8 +465,8 @@ vips_foreign_save_magick_buffer_build( VipsObject *object ) build( object ) ) return( -1 ); - if( !(obuf = ImagesToBlob( magick->image_info, magick->images, - &olen, magick->exception )) ) { + if( !(obuf = magick_images_to_blob( magick->image_info, magick->images, + &olen, magick->exception )) ) { magick_inherit_exception( magick->exception, magick->images ); magick_vips_error( class->nickname, magick->exception );