Merge branch 'master' into deftomat-master

This commit is contained in:
John Cupitt 2019-07-06 14:50:40 +01:00
commit 3871369d3e
11 changed files with 136 additions and 35 deletions

View File

@ -2,6 +2,9 @@
- add vips_image_get/set_array_int()
- disable webp alpha output if all frame fill the canvas and are solid
- support arrays of delays for animated images [deftomat]
- add "unlimited" flag to svgload
- 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
@ -16,6 +19,8 @@ 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]
- fewer warnings on tiffload [chregu]
21/9/18 started 8.8.0
- much faster smartcrop [lovell]

View File

@ -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.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.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.34.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
]
)
@ -1159,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"
@ -1475,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)

View File

@ -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]
*/
/*
@ -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;

View File

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

View File

@ -2,6 +2,8 @@
*
* 5/7/18
* - from niftisave.c
* 3/7/19 [lovell]
* - add "compression" option
*/
/*
@ -65,6 +67,10 @@ typedef struct _VipsForeignSaveHeif {
*/
gboolean lossless;
/* Compression format
*/
VipsForeignHeifCompression compression;
int page_width;
int page_height;
int n_pages;
@ -81,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;
@ -293,12 +299,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 );
}
@ -322,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 );
@ -378,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;
@ -401,6 +410,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 +425,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 +598,7 @@ vips_foreign_save_heif_buffer_init( VipsForeignSaveHeifBuffer *buffer )
*
* * @Q: %gint, quality factor
* * @lossless: %gboolean, enable lossless encoding
* * @compression: #VipsForeignHeifCompression, write with this compression
*
* Write a VIPS image to a file in HEIF format.
*
@ -588,6 +607,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 +637,7 @@ vips_heifsave( VipsImage *in, const char *filename, ... )
*
* * @Q: %gint, quality factor
* * @lossless: %gboolean, enable lossless encoding
* * @compression: #VipsForeignHeifCompression, write with this compression
*
* As vips_heifsave(), but save to a memory buffer.
*

View File

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

View File

@ -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.
*/

View File

@ -186,7 +186,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 );

View File

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

View File

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

View File

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