From 80648c2d2f551b75d094718229a6209d77ab3429 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 27 Jun 2019 17:19:53 +0100 Subject: [PATCH 1/9] text autofit could sometimes underfit The autofit loop would terminate if either width or height fitted exactly, but this could happen very early by chance. This patch makes it keep looping until it finds a dpi which just fits. See https://github.com/libvips/libvips/issues/1352 --- ChangeLog | 1 + libvips/create/text.c | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 581d82e3..62fe3419 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ magic number [przemyslawpluta] - remove 256 band limit in arithmetic.c [erdmann] - disable Orc if building with CET [lovell] - fix vipsthumbnail with pyr tiff [kleisauke] +- text autofit could occasionally terminate early [levmorozov] 21/9/18 started 8.8.0 - much faster smartcrop [lovell] diff --git a/libvips/create/text.c b/libvips/create/text.c index 7640b929..6a1cc1f5 100644 --- a/libvips/create/text.c +++ b/libvips/create/text.c @@ -28,6 +28,8 @@ * 16/3/19 * - add `justify` * - set Xoffset/Yoffset to ink left/top + * 27/6/19 + * - fitting could occasionally terminate early [levmorozov] */ /* @@ -58,8 +60,8 @@ */ /* -#define DEBUG */ +#define DEBUG #ifdef HAVE_CONFIG_H #include @@ -204,18 +206,13 @@ vips_text_get_extents( VipsText *text, VipsRect *extents ) return( 0 ); } -/* Return -ve for extents too small, 0 for a fit, +ve for extents too large. +/* Return -ve for extents too small, +ve for extents too large. */ static int vips_text_rect_difference( VipsRect *target, VipsRect *extents ) { - if( vips_rect_includesrect( target, extents ) ) { - if( target->width == extents->width || - target->height == extents->height ) - return( 0 ); - + if( vips_rect_includesrect( target, extents ) ) return( -1 ); - } else return( 1 ); } @@ -261,10 +258,9 @@ vips_text_autofit( VipsText *text ) previous_difference = difference; } - /* Hit the size, or we straddle the target. + /* Stop if we straddle the target. */ - if( difference == 0 || - difference != previous_difference ) + if( difference != previous_difference ) break; previous_difference = difference; From 01a92679b57ab5fdf24ece370cedacde45b17f2f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 27 Jun 2019 17:34:07 +0100 Subject: [PATCH 2/9] oop left some DEBUG turned on --- libvips/create/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvips/create/text.c b/libvips/create/text.c index 6a1cc1f5..a2d22a30 100644 --- a/libvips/create/text.c +++ b/libvips/create/text.c @@ -60,8 +60,8 @@ */ /* - */ #define DEBUG + */ #ifdef HAVE_CONFIG_H #include From 55e49831b801e05ddd974b1e2102fda7956c53f5 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 28 Jun 2019 13:48:18 +0100 Subject: [PATCH 3/9] add "unlimited" to svgload By default librsvg blocks SVGs > 10MB for security. This patch adds an "unlimited" flag to remove this check. We have to switch to using gio to get the librsvg API for this This needs testing on the platforms we support. We'll also need to bump the min version of librsvg we require in configure.ac. See https://github.com/libvips/libvips/issues/1354 --- ChangeLog | 1 + libvips/foreign/svgload.c | 40 +++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf0e16f0..1f37f015 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 20/6/19 started 8.9.0 - add vips_image_get/set_array_int() +- add "unlimited" flag to svgload 24/5/19 started 8.8.1 - improve realpath() use on older libc diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index a61ce8e5..4d6a054b 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -14,6 +14,9 @@ * - handle scaling of svg files missing width and height attributes * 22/3/18 lovell * - svgload was missing is_a + * 28/6/19 + * - add "unlimited" + * - requires us to use the gio API to librsvg */ /* @@ -107,6 +110,10 @@ typedef struct _VipsForeignLoadSvg { */ double cairo_scale; + /* Allow SVGs of any size. + */ + gboolean unlimited; + RsvgHandle *page; } VipsForeignLoadSvg; @@ -440,6 +447,13 @@ vips_foreign_load_svg_class_init( VipsForeignLoadSvgClass *class ) G_STRUCT_OFFSET( VipsForeignLoadSvg, scale ), 0.001, 100000.0, 1.0 ); + VIPS_ARG_BOOL( class, "unlimited", 23, + _( "Unlimited" ), + _( "Allow SVG of any size" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsForeignLoadSvg, unlimited ), + FALSE ); + } static void @@ -480,14 +494,20 @@ vips_foreign_load_svg_file_header( VipsForeignLoad *load ) { VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; VipsForeignLoadSvgFile *file = (VipsForeignLoadSvgFile *) load; + RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; GError *error = NULL; - if( !(svg->page = rsvg_handle_new_from_file( - file->filename, &error )) ) { + GFile *gfile; + + gfile = g_file_new_for_path( file->filename ); + if( !(svg->page = rsvg_handle_new_from_gfile_sync( + gfile, flags, NULL, &error )) ) { + g_object_unref( gfile ); vips_g_error( &error ); return( -1 ); } + g_object_unref( gfile ); VIPS_SETSTR( load->out->filename, file->filename ); @@ -558,14 +578,21 @@ vips_foreign_load_svg_buffer_header( VipsForeignLoad *load ) VipsForeignLoadSvg *svg = (VipsForeignLoadSvg *) load; VipsForeignLoadSvgBuffer *buffer = (VipsForeignLoadSvgBuffer *) load; + RsvgHandleFlags flags = svg->unlimited ? RSVG_HANDLE_FLAG_UNLIMITED : 0; GError *error = NULL; - if( !(svg->page = rsvg_handle_new_from_data( - buffer->buf->data, buffer->buf->length, &error )) ) { + GInputStream *gstream; + + gstream = g_memory_input_stream_new_from_data( + buffer->buf->data, buffer->buf->length, NULL ); + if( !(svg->page = rsvg_handle_new_from_stream_sync( + gstream, NULL, flags, NULL, &error )) ) { + g_object_unref( gstream ); vips_g_error( &error ); return( -1 ); } + g_object_unref( gstream ); return( vips_foreign_load_svg_header( load ) ); } @@ -612,6 +639,7 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) * * * @dpi: %gdouble, render at this DPI * * @scale: %gdouble, scale render by this factor + * * @unlimited: %gboolean, allow SVGs of any size * * Render a SVG file into a VIPS image. Rendering uses the librsvg library * and should be fast. @@ -622,6 +650,9 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer ) * This function only reads the image header and does not render any pixel * data. Rendering occurs when pixels are accessed. * + * SVGs larger than 10MB are normally blocked for security. Set @unlimited to + * allow SVGs of any size. + * * See also: vips_image_new_from_file(). * * Returns: 0 on success, -1 on error. @@ -650,6 +681,7 @@ vips_svgload( const char *filename, VipsImage **out, ... ) * * * @dpi: %gdouble, render at this DPI * * @scale: %gdouble, scale render by this factor + * * @unlimited: %gboolean, allow SVGs of any size * * Read a SVG-formatted memory block into a VIPS image. Exactly as * vips_svgload(), but read from a memory buffer. From 260f3284ff6e8b19df937403462e92782dd41037 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 28 Jun 2019 18:49:10 +0100 Subject: [PATCH 4/9] require librsvg >= 2.40 we need the UNLIMITED open API --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8741426f..7589edce 100644 --- a/configure.ac +++ b/configure.ac @@ -1039,12 +1039,12 @@ AC_ARG_WITH([rsvg], AS_HELP_STRING([--without-rsvg], [build without rsvg (default: test)])) if test x"$with_rsvg" != x"no"; then - PKG_CHECK_MODULES(RSVG, [librsvg-2.0 >= 2.34 cairo >= 1.2], - [AC_DEFINE(HAVE_RSVG,1,[define if you have librsvg-2.0 >= 2.34.0 and cairo >= 1.2 installed.]) + PKG_CHECK_MODULES(RSVG, [librsvg-2.0 >= 2.40 cairo >= 1.2], + [AC_DEFINE(HAVE_RSVG,1,[define if you have librsvg-2.0 >= 2.40.0 and cairo >= 1.2 installed.]) with_rsvg=yes PACKAGES_USED="$PACKAGES_USED librsvg-2.0 cairo" ], - [AC_MSG_WARN([librsvg-2.0 >= 2.34.0 or cairo >= 1.2 not found; disabling SVG load via rsvg]) + [AC_MSG_WARN([librsvg-2.0 >= 2.40.0 or cairo >= 1.2 not found; disabling SVG load via rsvg]) with_rsvg=no ] ) From c5147afdcd5ec2f3662a5d9783dc7966352f6be4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 29 Jun 2019 14:55:47 +0100 Subject: [PATCH 5/9] require 2.40.3 to get unlimited flag --- configure.ac | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 7589edce..0cf70507 100644 --- a/configure.ac +++ b/configure.ac @@ -1038,13 +1038,14 @@ fi AC_ARG_WITH([rsvg], AS_HELP_STRING([--without-rsvg], [build without rsvg (default: test)])) +# 2.40.3 so we get the UNLIMITED open flag if test x"$with_rsvg" != x"no"; then - PKG_CHECK_MODULES(RSVG, [librsvg-2.0 >= 2.40 cairo >= 1.2], - [AC_DEFINE(HAVE_RSVG,1,[define if you have librsvg-2.0 >= 2.40.0 and cairo >= 1.2 installed.]) + PKG_CHECK_MODULES(RSVG, [librsvg-2.0 >= 2.40.3 cairo >= 1.2], + [AC_DEFINE(HAVE_RSVG,1,[define if you have librsvg-2.0 >= 2.40.3 and cairo >= 1.2 installed.]) with_rsvg=yes PACKAGES_USED="$PACKAGES_USED librsvg-2.0 cairo" ], - [AC_MSG_WARN([librsvg-2.0 >= 2.40.0 or cairo >= 1.2 not found; disabling SVG load via rsvg]) + [AC_MSG_WARN([librsvg-2.0 >= 2.40.3 or cairo >= 1.2 not found; disabling SVG load via rsvg]) with_rsvg=no ] ) From 26100041e7e70f3bebd0376a315f1eccb5ae5206 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 2 Jul 2019 12:23:53 +0100 Subject: [PATCH 6/9] fewer warnings on tiffload We were setting TIFFTAG_JPEGCOLORMODE == JPEGCOLORMODE_RGB for *all* images, but libtiff warns if you use it on an image which is not jpg-compressed. Only set it for jpg-compressed images. See https://github.com/libvips/libvips/issues/1329 --- ChangeLog | 1 + libvips/foreign/tiff2vips.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62fe3419..d747a365 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ magic number [przemyslawpluta] - disable Orc if building with CET [lovell] - fix vipsthumbnail with pyr tiff [kleisauke] - text autofit could occasionally terminate early [levmorozov] +- fewer warnings on tiffload [chregu] 21/9/18 started 8.8.0 - much faster smartcrop [lovell] diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 6d0d5430..b7b20689 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -254,6 +254,7 @@ typedef struct _RtiffHeader { gboolean separate; int orientation; gboolean premultiplied; + uint16 compression; /* Result of TIFFIsTiled(). */ @@ -1331,9 +1332,12 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) uint32 data_length; void *data; - /* Request YCbCr expansion. + /* Request YCbCr expansion. libtiff complains if you do this for + * non-jpg images. */ - TIFFSetField( rtiff->tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB ); + if( rtiff->header.compression == COMPRESSION_JPEG ) + TIFFSetField( rtiff->tiff, + TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB ); out->Xsize = rtiff->header.width; out->Ysize = rtiff->header.height * rtiff->n; @@ -2074,7 +2078,6 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header ) { uint16 extra_samples_count; uint16 *extra_samples_types; - uint16 compression; if( !tfget32( rtiff->tiff, TIFFTAG_IMAGEWIDTH, &header->width ) || !tfget32( rtiff->tiff, TIFFTAG_IMAGELENGTH, &header->height ) || @@ -2088,8 +2091,8 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header ) return( -1 ); TIFFGetFieldDefaulted( rtiff->tiff, - TIFFTAG_COMPRESSION, &compression ); - if( compression == COMPRESSION_JPEG ) + TIFFTAG_COMPRESSION, &header->compression ); + if( header->compression == COMPRESSION_JPEG ) /* We want to always expand subsampled YCBCR images to full * RGB. */ From 42f9f78c869e56dca27774e9524d3df5c651812f Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Wed, 3 Jul 2019 13:07:55 +0100 Subject: [PATCH 7/9] heifsave: expose compression option improve error messaging, add further suffixes --- libvips/foreign/heifload.c | 5 ++++- libvips/foreign/heifsave.c | 28 ++++++++++++++++++++++++---- libvips/include/vips/enumtypes.h | 2 ++ libvips/include/vips/foreign.h | 17 +++++++++++++++++ libvips/iofuncs/enumtypes.c | 20 ++++++++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/libvips/foreign/heifload.c b/libvips/foreign/heifload.c index 73bceab2..624b73dc 100644 --- a/libvips/foreign/heifload.c +++ b/libvips/foreign/heifload.c @@ -146,7 +146,8 @@ void vips__heif_error( struct heif_error *error ) { if( error->code ) - vips_error( "heifload", "%s", error->message ); + vips_error( "heif", "%s (%d.%d)", error->message, error->code, + error->subcode ); } static const char *heif_magic[] = { @@ -814,6 +815,8 @@ vips_foreign_load_heif_file_header( VipsForeignLoad *load ) const char *vips__heif_suffs[] = { ".heic", + ".heif", + ".avif", NULL }; diff --git a/libvips/foreign/heifsave.c b/libvips/foreign/heifsave.c index f8fea788..b6d22c1e 100644 --- a/libvips/foreign/heifsave.c +++ b/libvips/foreign/heifsave.c @@ -65,6 +65,10 @@ typedef struct _VipsForeignSaveHeif { */ gboolean lossless; + /* Compression format + */ + VipsForeignHeifCompression compression; + int page_width; int page_height; int n_pages; @@ -293,12 +297,15 @@ vips_foreign_save_heif_build( VipsObject *object ) build( object ) ) return( -1 ); - /* TODO ... should be a param? the other useful one is AVC. - */ error = heif_context_get_encoder_for_format( heif->ctx, - heif_compression_HEVC, &heif->encoder ); + heif->compression, &heif->encoder ); if( error.code ) { - vips__heif_error( &error ); + if ( error.code == heif_error_Unsupported_filetype ) { + vips_error( "heifsave", "%s", _( "Unsupported compression" ) ); + } + else { + vips__heif_error( &error ); + } return( -1 ); } @@ -401,6 +408,14 @@ vips_foreign_save_heif_class_init( VipsForeignSaveHeifClass *class ) G_STRUCT_OFFSET( VipsForeignSaveHeif, lossless ), FALSE ); + VIPS_ARG_ENUM( class, "compression", 14, + _( "compression" ), + _( "Compression format" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsForeignSaveHeif, compression ), + VIPS_TYPE_FOREIGN_HEIF_COMPRESSION, + VIPS_FOREIGN_HEIF_COMPRESSION_HEVC ); + } static void @@ -408,6 +423,7 @@ vips_foreign_save_heif_init( VipsForeignSaveHeif *heif ) { heif->ctx = heif_context_alloc(); heif->Q = 50; + heif->compression = VIPS_FOREIGN_HEIF_COMPRESSION_HEVC; } typedef struct _VipsForeignSaveHeifFile { @@ -580,6 +596,7 @@ vips_foreign_save_heif_buffer_init( VipsForeignSaveHeifBuffer *buffer ) * * * @Q: %gint, quality factor * * @lossless: %gboolean, enable lossless encoding + * * @compression: use this #VipsForeignHeifCompression * * Write a VIPS image to a file in HEIF format. * @@ -588,6 +605,8 @@ vips_foreign_save_heif_buffer_init( VipsForeignSaveHeifBuffer *buffer ) * * Set @lossless %TRUE to switch to lossless compression. * + * Use @compression to set the encoder e.g. HEVC, AVC, AV1 + * * See also: vips_image_write_to_file(), vips_heifload(). * * Returns: 0 on success, -1 on error. @@ -616,6 +635,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) * * * @Q: %gint, quality factor * * @lossless: %gboolean, enable lossless encoding + * * @compression: use this #VipsForeignHeifCompression * * As vips_heifsave(), but save to a memory buffer. * diff --git a/libvips/include/vips/enumtypes.h b/libvips/include/vips/enumtypes.h index 87cea5fd..2de73711 100644 --- a/libvips/include/vips/enumtypes.h +++ b/libvips/include/vips/enumtypes.h @@ -74,6 +74,8 @@ GType vips_foreign_dz_depth_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_FOREIGN_DZ_DEPTH (vips_foreign_dz_depth_get_type()) GType vips_foreign_dz_container_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_FOREIGN_DZ_CONTAINER (vips_foreign_dz_container_get_type()) +GType vips_foreign_heif_compression_get_type (void) G_GNUC_CONST; +#define VIPS_TYPE_FOREIGN_HEIF_COMPRESSION (vips_foreign_heif_compression_get_type()) /* enumerations from "../../../libvips/include/vips/image.h" */ GType vips_demand_style_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_DEMAND_STYLE (vips_demand_style_get_type()) diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 6b3ea0a6..eb8a425d 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -623,6 +623,23 @@ typedef enum { int vips_dzsave( VipsImage *in, const char *name, ... ) __attribute__((sentinel)); +/** + * VipsForeignHeifCompression: + * @VIPS_FOREIGN_HEIF_COMPRESSION_HEVC: x265 + * @VIPS_FOREIGN_HEIF_COMPRESSION_AVC: x264 + * @VIPS_FOREIGN_HEIF_COMPRESSION_JPEG: jpeg + * @VIPS_FOREIGN_HEIF_COMPRESSION_AV1: aom + * + * The compression format to use inside a HEIF container. + */ +typedef enum { + VIPS_FOREIGN_HEIF_COMPRESSION_HEVC = 1, + VIPS_FOREIGN_HEIF_COMPRESSION_AVC = 2, + VIPS_FOREIGN_HEIF_COMPRESSION_JPEG = 3, + VIPS_FOREIGN_HEIF_COMPRESSION_AV1 = 4, + VIPS_FOREIGN_HEIF_COMPRESSION_LAST +} VipsForeignHeifCompression; + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index d5ba3f3d..6628e3c2 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -657,6 +657,26 @@ vips_foreign_dz_container_get_type( void ) return( etype ); } +GType +vips_foreign_heif_compression_get_type( void ) +{ + static GType etype = 0; + + if( etype == 0 ) { + static const GEnumValue values[] = { + {VIPS_FOREIGN_HEIF_COMPRESSION_HEVC, "VIPS_FOREIGN_HEIF_COMPRESSION_HEVC", "hevc"}, + {VIPS_FOREIGN_HEIF_COMPRESSION_AVC, "VIPS_FOREIGN_HEIF_COMPRESSION_AVC", "avc"}, + {VIPS_FOREIGN_HEIF_COMPRESSION_JPEG, "VIPS_FOREIGN_HEIF_COMPRESSION_JPEG", "jpeg"}, + {VIPS_FOREIGN_HEIF_COMPRESSION_AV1, "VIPS_FOREIGN_HEIF_COMPRESSION_AV1", "av1"}, + {VIPS_FOREIGN_HEIF_COMPRESSION_LAST, "VIPS_FOREIGN_HEIF_COMPRESSION_LAST", "last"}, + {0, NULL, NULL} + }; + + etype = g_enum_register_static( "VipsForeignHeifCompression", values ); + } + + return( etype ); +} /* enumerations from "../../libvips/include/vips/image.h" */ GType vips_demand_style_get_type( void ) From 8cb2b613b7193e3d886ac68336ebc5eb28845524 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 3 Jul 2019 15:04:58 +0100 Subject: [PATCH 8/9] note new heifsave param in changelog plus tiny reformatting --- ChangeLog | 3 ++- libvips/foreign/heifsave.c | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdc3f499..d4beb5d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 20/6/19 started 8.9.0 - add vips_image_get/set_array_int() - add "unlimited" flag to svgload -- disable webp alpha output if all frame fill the canvas and are solid +- disable webp alpha output if all frames fill the canvas and are solid +- add "compression" option to heifsave [lovell] 24/5/19 started 8.8.1 - improve realpath() use on older libc diff --git a/libvips/foreign/heifsave.c b/libvips/foreign/heifsave.c index b6d22c1e..f72f1953 100644 --- a/libvips/foreign/heifsave.c +++ b/libvips/foreign/heifsave.c @@ -2,6 +2,8 @@ * * 5/7/18 * - from niftisave.c + * 3/7/19 [lovell] + * - add "compression" option */ /* @@ -85,7 +87,7 @@ typedef struct _VipsForeignSaveHeif { */ struct heif_image *img; - /* The libheif memory area will fill with pixels from the libvips + /* The libheif memory area we fill with pixels from the libvips * pipe. */ uint8_t *data; @@ -300,12 +302,12 @@ vips_foreign_save_heif_build( VipsObject *object ) error = heif_context_get_encoder_for_format( heif->ctx, heif->compression, &heif->encoder ); if( error.code ) { - if ( error.code == heif_error_Unsupported_filetype ) { - vips_error( "heifsave", "%s", _( "Unsupported compression" ) ); - } - else { + if( error.code == heif_error_Unsupported_filetype ) + vips_error( "heifsave", + "%s", _( "Unsupported compression" ) ); + else vips__heif_error( &error ); - } + return( -1 ); } @@ -329,8 +331,8 @@ vips_foreign_save_heif_build( VipsObject *object ) heif->page_height = vips_image_get_page_height( save->ready ); heif->n_pages = save->ready->Ysize / heif->page_height; - /* Make a heif image the size of a page. We repeatedly fill this with - * sink_disc() and write a frame each time it fills. + /* Make a heif image the size of a page. We send sink_disc() output + * here and write a frame each time it fills. */ error = heif_image_create( heif->page_width, heif->page_height, heif_colorspace_RGB, heif_chroma_interleaved_RGB, &heif->img ); @@ -385,7 +387,7 @@ vips_foreign_save_heif_class_init( VipsForeignSaveHeifClass *class ) gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; - object_class->nickname = "heifsave"; + object_class->nickname = "heifsave_base"; object_class->description = _( "save image in HEIF format" ); object_class->build = vips_foreign_save_heif_build; @@ -596,7 +598,7 @@ vips_foreign_save_heif_buffer_init( VipsForeignSaveHeifBuffer *buffer ) * * * @Q: %gint, quality factor * * @lossless: %gboolean, enable lossless encoding - * * @compression: use this #VipsForeignHeifCompression + * * @compression: #VipsForeignHeifCompression, write with this compression * * Write a VIPS image to a file in HEIF format. * @@ -635,7 +637,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... ) * * * @Q: %gint, quality factor * * @lossless: %gboolean, enable lossless encoding - * * @compression: use this #VipsForeignHeifCompression + * * @compression: #VipsForeignHeifCompression, write with this compression * * As vips_heifsave(), but save to a memory buffer. * From 1c30a8567cb06eeefce3eb86f53b5ab9a14a8646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Fri, 5 Jul 2019 13:14:32 +0200 Subject: [PATCH 9/9] [webp] Use well documented use_sharp_yuv option instead of preprocessing --- configure.ac | 6 +++--- libvips/foreign/vips2webp.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 0cf70507..fbf34be9 100644 --- a/configure.ac +++ b/configure.ac @@ -1160,14 +1160,14 @@ if test x"$with_cfitsio" != x"no"; then ) fi -# libwebp ... target 0.5+ to reduce complication +# libwebp ... target 0.6+ to reduce complication # webp has the stuff for handling metadata in two separate libraries -- we # insit on having all of them AC_ARG_WITH([libwebp], AS_HELP_STRING([--without-libwebp], [build without libwebp (default: test)])) if test x"$with_libwebp" != x"no"; then - PKG_CHECK_MODULES(LIBWEBP, libwebp >= 0.5 libwebpmux >= 0.5 libwebpdemux >= 0.5, + PKG_CHECK_MODULES(LIBWEBP, libwebp >= 0.6 libwebpmux >= 0.6 libwebpdemux >= 0.6, [AC_DEFINE(HAVE_LIBWEBP,1,[define if you have libwebp/libwebpmux/libwebpdemux installed.]) with_libwebp=yes PACKAGES_USED="$PACKAGES_USED libwebp libwebpmux libwebpdemux" @@ -1476,7 +1476,7 @@ SVG import with librsvg-2.0: $with_rsvg zlib: $with_zlib file import with cfitsio: $with_cfitsio file import/export with libwebp: $with_libwebp - (requires libwebp, libwebpmux, libwebpdemux 0.5.0 or later) + (requires libwebp, libwebpmux, libwebpdemux 0.6.0 or later) text rendering with pangoft2: $with_pangoft2 file import/export with libpng: $with_png (requires libpng-1.2.9 or later) diff --git a/libvips/foreign/vips2webp.c b/libvips/foreign/vips2webp.c index b45a1d4b..91ffd55a 100644 --- a/libvips/foreign/vips2webp.c +++ b/libvips/foreign/vips2webp.c @@ -184,7 +184,7 @@ vips_webp_write_init( VipsWebPWrite *write, VipsImage *image, if( near_lossless ) write->config.near_lossless = Q; if( smart_subsample ) - write->config.preprocessing |= 4; + write->config.use_sharp_yuv = 1; if( !WebPValidateConfig( &write->config ) ) { vips_webp_write_unset( write );