From 48ef2154790289fe3a4802f9313b83e7342fa7be Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 2 May 2016 09:55:16 +0100 Subject: [PATCH] tiny fixups for the webp commit just small formatting changes, plus an unneeded var see https://github.com/jcupitt/libvips/pull/430 --- ChangeLog | 3 +++ TODO | 2 ++ configure.ac | 8 +++--- libvips/foreign/foreign.c | 46 ++++++++++++++++++++++++---------- libvips/foreign/vips2webp.c | 37 ++++++++++++++------------- libvips/include/vips/foreign.h | 6 ++--- 6 files changed, 64 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbb50c50..859045b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +1/5/16 started 8.4 +- many more wepsave options [Felix Bünemann] + 15/4/16 started 8.3.1 - rename vips wrapper script, it was still vips-8.2, thanks Benjamin - export C++ operator overloads for MSVC linking [Lovell] diff --git a/TODO b/TODO index cf0dcd7a..c16cf38d 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +- add "*" before each optional arg description + - I like the new int mask creator in reducev, can we use it in im_vips2imask() as well? diff --git a/configure.ac b/configure.ac index 3bdf4466..4ddb37fe 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [8.3.1], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [8.4.0], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -17,8 +17,8 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [8]) -m4_define([vips_minor_version], [3]) -m4_define([vips_micro_version], [1]) +m4_define([vips_minor_version], [4]) +m4_define([vips_micro_version], [0]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=46 -LIBRARY_REVISION=1 +LIBRARY_REVISION=2 LIBRARY_AGE=4 # patched into include/vips/version.h diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index e012cb2f..2b7cffdc 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -2457,12 +2457,27 @@ vips_webpload_buffer( void *buf, size_t len, VipsImage **out, ... ) * * Optional arguments: * - * @Q: quality factor - * @lossless: enables lossless compression - * @preset: #VipsForeignWebpPreset choose lossy compression preset - * @smart_subsample: enables high quality chroma subsampling - * @near_lossless: use preprocessing in lossless mode (controlled by Q) - * @alpha_q: set alpha quality in lossless mode + * * @Q: %gint quality factor + * * @lossless: %gboolean enables lossless compression + * * @preset: #VipsForeignWebpPreset choose lossy compression preset + * * @smart_subsample: %gboolean enables high quality chroma subsampling + * * @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q) + * * @alpha_q: %gint set alpha quality in lossless mode + * + * Write an image to a file in WebP format. + * + * Use @Q to set the WebP quality factor. It has the range 0 - 100, with the + * default 75. + * + * Use @preset to hint the image type to lossy compressor. The default is + * #VIPS_FOREIGN_WEBP_PRESET_DEFAULT. + * + * Set @smart_subsample to enable high quality chroma subsampling. + * + * Use @alpha_q to set the quality for the alpha channel in lossy mode. It has + * the range 1 - 100, with the default 100. + * + * Set @lossless to enable lossless save. * * See also: vips_webpload(), vips_image_write_to_file(). * @@ -2490,18 +2505,18 @@ vips_webpsave( VipsImage *in, const char *filename, ... ) * * Optional arguments: * - * @Q: JPEG quality factor - * @lossless: enables lossless compression + * @Q: %gint quality factor + * @lossless: %gboolean enables lossless compression * @preset: #VipsForeignWebpPreset choose lossy compression preset - * @smart_subsample: enables high quality chroma subsampling - * @near_lossless: use preprocessing in lossless mode (controlled by Q) - * @alpha_q: set alpha quality in lossless mode + * @smart_subsample: %gboolean enables high quality chroma subsampling + * @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q) + * @alpha_q: %gint set alpha quality in lossless mode * * As vips_webpsave(), but save to a memory buffer. * * The address of the buffer is returned in @obuf, the length of the buffer in * @olen. You are responsible for freeing the buffer with g_free() when you - * are done with it. The buffer is freed for you on error. + * are done with it. * * See also: vips_webpsave(). * @@ -2542,7 +2557,12 @@ vips_webpsave_buffer( VipsImage *in, void **buf, size_t *len, ... ) * * Optional arguments: * - * @Q: quality factor + * @Q: %gint quality factor + * @lossless: %gboolean enables lossless compression + * @preset: #VipsForeignWebpPreset choose lossy compression preset + * @smart_subsample: %gboolean enables high quality chroma subsampling + * @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q) + * @alpha_q: %gint set alpha quality in lossless mode * * As vips_webpsave(), but save as a mime webp on stdout. * diff --git a/libvips/foreign/vips2webp.c b/libvips/foreign/vips2webp.c index 17726218..05301d85 100644 --- a/libvips/foreign/vips2webp.c +++ b/libvips/foreign/vips2webp.c @@ -4,6 +4,8 @@ * - from vips2jpeg.c * 31/5/16 * - buffer write ignored lossless, thanks aaron42net + * 2/5/16 Felix Bünemann + * - used advanced encoding API, expose controls */ /* @@ -99,34 +101,36 @@ init_memory_writer( VipsWebPMemoryWriter *writer ) { static int memory_write( const uint8_t *data, size_t data_size, const WebPPicture *picture ) { - VipsWebPMemoryWriter* const w = (VipsWebPMemoryWriter*) picture->custom_ptr; + VipsWebPMemoryWriter * const writer = + (VipsWebPMemoryWriter*) picture->custom_ptr; + size_t next_size; - if( w == NULL ) + if( !writer ) return( 0 ); - next_size = w->size + data_size; + next_size = writer->size + data_size; - if( next_size > w->max_size ) { + if( next_size > writer->max_size ) { uint8_t *new_mem; const size_t next_max_size = - VIPS_MAX( 8192, VIPS_MAX( next_size, w->max_size * 2 ) ); + VIPS_MAX( 8192, VIPS_MAX( next_size, + writer->max_size * 2 ) ); - new_mem = (uint8_t*) g_try_malloc( next_max_size ); - if( new_mem == NULL ) + if( !(new_mem = (uint8_t*) g_try_malloc( next_max_size )) ) return( 0 ); - if( w->size > 0 ) - memcpy( new_mem, w->mem, w->size ); + if( writer->size > 0 ) + memcpy( new_mem, writer->mem, writer->size ); - g_free( w->mem ); - w->mem = new_mem; - w->max_size = next_max_size; + g_free( writer->mem ); + writer->mem = new_mem; + writer->max_size = next_max_size; } if( data_size > 0 ) { - memcpy( w->mem + w->size, data, data_size ); - w->size += data_size; + memcpy( writer->mem + writer->size, data, data_size ); + writer->size += data_size; } return( 1 ); @@ -142,7 +146,7 @@ write_webp( WebPPicture *pic, VipsImage *in, WebPConfig config; webp_import import; - if ( !WebPConfigPreset(&config, get_preset( preset ), Q) ) { + if ( !WebPConfigPreset( &config, get_preset( preset ), Q ) ) { vips_error( "vips2webp", "%s", _( "config version error" ) ); return( -1 ); @@ -178,7 +182,7 @@ write_webp( WebPPicture *pic, VipsImage *in, "%s", _( "smart_subsample unsupported" ) ); #endif - if( !WebPValidateConfig(&config) ) { + if( !WebPValidateConfig( &config ) ) { vips_error( "vips2webp", "%s", _( "invalid configuration" ) ); return( -1 ); @@ -269,7 +273,6 @@ vips__webp_write_buffer( VipsImage *in, void **obuf, size_t *olen, { WebPPicture pic; VipsWebPMemoryWriter writer; - FILE *fp; if( !WebPPictureInit( &pic ) ) { vips_error( "vips2webp", diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index a3a9af8e..218b7470 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -341,11 +341,9 @@ int vips_jpegsave_mime( VipsImage *in, ... ) /** * VipsForeignWebpPreset: * @VIPS_FOREIGN_WEBP_PRESET_DEFAULT: default preset - * @VIPS_FOREIGN_WEBP_PRESET_PICTURE: digital picture, like portrait, - * inner shot + * @VIPS_FOREIGN_WEBP_PRESET_PICTURE: digital picture, like portrait, inner shot * @VIPS_FOREIGN_WEBP_PRESET_PHOTO: outdoor photograph, with natural lighting - * @VIPS_FOREIGN_WEBP_PRESET_DRAWING: hand or line drawing, with high-contrast - * details + * @VIPS_FOREIGN_WEBP_PRESET_DRAWING: hand or line drawing, with high-contrast details * @VIPS_FOREIGN_WEBP_PRESET_ICON: small-sized colorful images * @VIPS_FOREIGN_WEBP_PRESET_TEXT: text-like *