Merge pull request #1224 from DarthSim/feature/gm_magicksave

vips_magicksave for GraphicsMagick
This commit is contained in:
John Cupitt 2019-02-06 09:44:31 +00:00 committed by GitHub
commit 71664346c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 8 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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,

View File

@ -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 );