From b8a28f1a8dbf7a570f4e4c046fa3dfbc71ef0fca Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 7 Oct 2015 14:48:32 +0100 Subject: [PATCH] add vips7 wrapper for magickload_buffer see https://github.com/jcupitt/ruby-vips/issues/69 --- ChangeLog | 3 +++ libvips/deprecated/im_magick2vips.c | 20 ++++++++++++++++++++ libvips/include/vips/format.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2e19248f..2a321999 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +7/10/15 started 8.2.0 +- added im_bufmagick2vips(), a vips7 wrapper for magick load from buffer + 7/5/15 starteld 8.1.0 - add vips_premultiply(), vips_unpremultiply() - change the alpha range rules for vips_flatten() to match vips_premultiply() diff --git a/libvips/deprecated/im_magick2vips.c b/libvips/deprecated/im_magick2vips.c index 5e0d4c95..36a9c7a7 100644 --- a/libvips/deprecated/im_magick2vips.c +++ b/libvips/deprecated/im_magick2vips.c @@ -97,3 +97,23 @@ vips_format_magick_init( VipsFormatMagick *object ) } G_DEFINE_TYPE( VipsFormatMagick, vips_format_magick, VIPS_TYPE_FORMAT ); + +int +im_bufmagick2vips( void *buf, size_t len, IMAGE *out, gboolean header_only ) +{ + VipsImage *t; + + /* header_only is automatic ... this call will only decompress on + * pixel access. + */ + + if( vips_magickload_buffer( buf, len, &t, NULL ) ) + return( -1 ); + if( vips_image_write( t, out ) ) { + g_object_unref( t ); + return( -1 ); + } + g_object_unref( t ); + + return( 0 ); +} diff --git a/libvips/include/vips/format.h b/libvips/include/vips/format.h index 8a87d038..afa2d629 100644 --- a/libvips/include/vips/format.h +++ b/libvips/include/vips/format.h @@ -137,6 +137,8 @@ int im_tile_cache( VipsImage *in, VipsImage *out, int tile_width, int tile_height, int max_tiles ); int im_magick2vips( const char *filename, VipsImage *out ); +int im_bufmagick2vips( void *buf, size_t len, + VipsImage *out, gboolean header_only ); int im_exr2vips( const char *filename, VipsImage *out );