From e0a5d281001e4b64cc3efc35ad1dee8a84ac58f6 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 21 Apr 2015 14:29:44 +0100 Subject: [PATCH] add vips_vipsload() vips_vipssave() to C API we didn't have these in the C API before, for some reason --- ChangeLog | 1 + libvips/foreign/foreign.c | 57 ++++++++++++++++++++++++++++++++-- libvips/include/vips/foreign.h | 5 +++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d72e36cf..5dd748c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ - better conversion to greyscale, thanks bkw - add vips_image_copy_memory(), improves stability with heavy threading - jpegsave supports new mozjpeg features [lovell] +- add vips_vipsload(), vips_vipssave() ... why not 26/3/15 started 7.42.4 - im_maxpos_avg() avoids NaN diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 9b218fd1..70378855 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -371,11 +371,12 @@ vips_foreign_init( VipsForeign *object ) */ static void * -file_add_class( VipsForeignClass *file, GSList **files ) +file_add_class( VipsForeignClass *class, GSList **files ) { - /* Append so we don't reverse the list of files. + /* Append so we don't reverse the list of files. Sort will not reorder + * items of equal priority. */ - *files = g_slist_append( *files, file ); + *files = g_slist_append( *files, class ); return( NULL ); } @@ -1681,6 +1682,56 @@ vips_foreign_operation_init( void ) #endif /*HAVE_OPENEXR*/ } +/** + * vips_vipsload: + * @filename: file to load + * @out: decompressed image + * @...: %NULL-terminated list of optional named arguments + * + * Read in a vips image. + * + * See also: vips_vipssave(). + * + * Returns: 0 on success, -1 on error. + */ +int +vips_vipsload( const char *filename, VipsImage **out, ... ) +{ + va_list ap; + int result; + + va_start( ap, out ); + result = vips_call_split( "vipsload", ap, filename, out ); + va_end( ap ); + + return( result ); +} + +/** + * vips_vipssave: + * @in: image to save + * @filename: file to write to + * @...: %NULL-terminated list of optional named arguments + * + * Write @in to @filename in VIPS format. + * + * See also: vips_vipsload(). + * + * Returns: 0 on success, -1 on error. + */ +int +vips_vipssave( VipsImage *in, const char *filename, ... ) +{ + va_list ap; + int result; + + va_start( ap, filename ); + result = vips_call_split( "vipssave", ap, in, filename ); + va_end( ap ); + + return( result ); +} + /** * vips_magickload: * @filename: file to load diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 4a22920d..e2925fc0 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -316,6 +316,11 @@ GType vips_foreign_save_get_type( void ); const char *vips_foreign_find_save( const char *filename ); const char *vips_foreign_find_save_buffer( const char *suffix ); +int vips_vipsload( const char *filename, VipsImage **out, ... ) + __attribute__((sentinel)); +int vips_vipssave( VipsImage *in, const char *filename, ... ) + __attribute__((sentinel)); + int vips_openslideload( const char *filename, VipsImage **out, ... ) __attribute__((sentinel));