Merge branch 'master' into ome-tiff-pyramid

This commit is contained in:
John Cupitt 2020-05-22 16:12:00 +01:00
commit 6a8f128831
9 changed files with 73 additions and 24 deletions

View File

@ -20,6 +20,8 @@
- better handling of unaligned reads in multipage tiffs [petoor]
- mark old --delete option to vipsthumbnail as deprecated [UweOhse]
- png save with a bad ICC profile just gives a warning
- add "premultipled" option to vips_affine(), clarified vips_resize()
behaviour with alpha channels
24/4/20 started 8.9.3
- better iiif tile naming [IllyaMoskvin]

View File

@ -855,14 +855,16 @@ if test x"$with_heif" != x"no"; then
PKG_CHECK_MODULES(HEIF, libheif,
[with_heif=yes
have_h265_decoder=`$PKG_CONFIG libheif --variable builtin_h265_decoder`
have_avif_decoder=`$PKG_CONFIG libheif --variable builtin_avif_decoder`
# test for !=no so that we work for older libheif which does not have
# this variable
if test x"$have_h265_decoder" != x"no"; then
if test x"$have_h265_decoder" != x"no" -o x"$have_avif_decoder" = x"yes"; then
AC_DEFINE(HAVE_HEIF_DECODER,1,
[define if your libheif has decode support.])
fi
have_h265_encoder=`$PKG_CONFIG libheif --variable builtin_h265_encoder`
if test x"$have_h265_encoder" != x"no"; then
have_avif_encoder=`$PKG_CONFIG libheif --variable builtin_avif_encoder`
if test x"$have_h265_encoder" != x"no" -o x"$have_avif_encoder" = x"yes"; then
AC_DEFINE(HAVE_HEIF_ENCODER,1,
[define if your libheif has encode support.])
fi
@ -872,6 +874,8 @@ if test x"$with_heif" != x"no"; then
with_heif=no
have_h265_decoder=
have_h265_encoder=
have_avif_decoder=
have_avif_encoder=
]
)
fi

View File

@ -30,6 +30,8 @@
* - set Xoffset/Yoffset to ink left/top
* 27/6/19
* - fitting could occasionally terminate early [levmorozov]
* 16/5/20 [keiviv]
* - don't add fontfiles repeatedly
*/
/*
@ -103,6 +105,10 @@ typedef VipsCreateClass VipsTextClass;
G_DEFINE_TYPE( VipsText, vips_text, VIPS_TYPE_CREATE );
/* ... single-thread the body of vips_text() with this.
*/
static GMutex *vips_text_lock = NULL;
/* Just have one of these and reuse it.
*
* This does not unref cleanly on many platforms, so we will leak horribly
@ -111,9 +117,10 @@ G_DEFINE_TYPE( VipsText, vips_text, VIPS_TYPE_CREATE );
*/
static PangoFontMap *vips_text_fontmap = NULL;
/* ... single-thread the body of vips_text() with this.
/* All the fontfiles we've loaded. fontconfig lets you add a fontfile
* repeatedly, and we obviously don't want that.
*/
static GMutex *vips_text_lock = NULL;
static GHashTable *vips_text_fontfiles = NULL;
static void
vips_text_dispose( GObject *gobject )
@ -350,17 +357,26 @@ vips_text_build( VipsObject *object )
if( !vips_text_fontmap )
vips_text_fontmap = pango_ft2_font_map_new();
if( !vips_text_fontfiles )
vips_text_fontfiles =
g_hash_table_new( g_str_hash, g_str_equal );
text->context = pango_font_map_create_context(
PANGO_FONT_MAP( vips_text_fontmap ) );
if( text->fontfile &&
!FcConfigAppFontAddFile( NULL,
!g_hash_table_lookup( vips_text_fontfiles, text->fontfile ) ) {
if( !FcConfigAppFontAddFile( NULL,
(const FcChar8 *) text->fontfile ) ) {
vips_error( class->nickname,
_( "unable to load font \"%s\"" ), text->fontfile );
g_mutex_unlock( vips_text_lock );
return( -1 );
vips_error( class->nickname,
_( "unable to load font \"%s\"" ),
text->fontfile );
g_mutex_unlock( vips_text_lock );
return( -1 );
}
g_hash_table_insert( vips_text_fontfiles,
text->fontfile,
g_strdup( text->fontfile ) );
}
/* If our caller set height and not dpi, we adjust dpi until
@ -543,7 +559,7 @@ vips_text_init( VipsText *text )
* * @fontfile: %gchararray, load this font file
* * @width: %gint, image should be no wider than this many pixels
* * @height: %gint, image should be no higher than this many pixels
* * @align: #VipsAlign, left/centre/right alignment
* * @align: #VipsAlign, set justification alignment
* * @justify: %gboolean, justify lines
* * @dpi: %gint, render at this resolution
* * @autofit_dpi: %gint, read out auto-fitted DPI
@ -564,11 +580,12 @@ vips_text_init( VipsText *text )
*
* @width is the number of pixels to word-wrap at. Lines of text wider than
* this will be broken at word boundaries.
* @align can be used to set the alignment style for multi-line
* text. Note that the output image can be wider than @width if there are no
* word breaks, or narrower if the lines don't break exactly at @width.
*
* Set @justify to turn on line justification.
* @align can be used to set the alignment style for multi-line
* text to the low (left) edge centre, or high (right) edge. Note that the
* output image can be wider than @width if there are no
* word breaks, or narrower if the lines don't break exactly at @width.
*
* @height is the maximum number of pixels high the generated text can be. This
* only takes effect when @dpi is not set, and @width is set, making a box.

View File

@ -69,7 +69,7 @@
* to be a slow way to do it. This is where the draw operations come in.
*
* To use these operations, use vips_copy() to make a copy of the image you
* want to modify, to ensure that no one else is using it, then call a
* want to modify to ensure that no one else is using it, then call a
* series of draw operations.
* Once you are done drawing, return to normal use of vips operations. Any time
* you want to start drawing again, you'll need to copy again.

View File

@ -418,10 +418,8 @@ vips_image_resolution_from_exif( VipsImage *image, ExifData *ed )
switch( unit ) {
case 1:
/* No unit ... just pass the fields straight to vips.
/* No units, instead xres / yres gives the pixel aspect ratio.
*/
vips_image_set_string( image,
VIPS_META_RESOLUTION_UNIT, "none" );
break;
case 2:

View File

@ -237,7 +237,8 @@ static const char *heif_magic[] = {
"ftyphevm", /* Multiview sequence */
"ftyphevs", /* Scaleable sequence */
"ftypmif1", /* Nokia alpha_ image */
"ftypmsf1" /* Nokia animation image */
"ftypmsf1", /* Nokia animation image */
"ftypavif" /* AV1 image format */
};
/* THe API has:

View File

@ -506,10 +506,11 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
break;
}
/* Get the jfif resolution. exif may overwrite this later.
/* Get the jfif resolution. exif may overwrite this later. Default to
* 72dpi (as EXIF does).
*/
xres = 1.0;
yres = 1.0;
xres = 72.0 / 25.4;
yres = 72.0 / 25.4;
if( cinfo->saw_JFIF_marker &&
cinfo->X_density != 1U &&
cinfo->Y_density != 1U ) {

View File

@ -88,6 +88,8 @@
* - add "background" parameter
* - better clipping means we have no jaggies on edges
* - premultiply alpha
* 18/5/20
* - add "premultiplied" flag
*/
/*
@ -166,6 +168,10 @@ typedef struct _VipsAffine {
*/
VipsPel *ink;
/* True if the input is already premultiplied (and we don't need to).
*/
gboolean premultiplied;
} VipsAffine;
typedef VipsResampleClass VipsAffineClass;
@ -524,11 +530,13 @@ vips_affine_build( VipsObject *object )
affine->trn.idx -= 1;
affine->trn.idy -= 1;
/* If there's an alpha, we have to premultiply before resampling. See
/* If there's an alpha and we've not premultiplied, we have to
* premultiply before resampling. See
* https://github.com/libvips/libvips/issues/291
*/
have_premultiplied = FALSE;
if( vips_image_hasalpha( in ) ) {
if( vips_image_hasalpha( in ) &&
!affine->premultiplied ) {
if( vips_premultiply( in, &t[3], NULL ) )
return( -1 );
have_premultiplied = TRUE;
@ -680,6 +688,13 @@ vips_affine_class_init( VipsAffineClass *class )
G_STRUCT_OFFSET( VipsAffine, background ),
VIPS_TYPE_ARRAY_DOUBLE );
VIPS_ARG_BOOL( class, "premultiplied", 117,
_( "Premultiplied" ),
_( "Images have premultiplied alpha" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsAffine, premultiplied ),
FALSE );
}
static void
@ -709,6 +724,7 @@ vips_affine_init( VipsAffine *affine )
* * @ody: %gdouble, output vertical offset
* * @extend: #VipsExtend how to generate new pixels
* * @background: #VipsArrayDouble colour for new pixels
* * @premultiplied: %gboolean, images are already premultiplied
*
* This operator performs an affine transform on an image using @interpolate.
*
@ -737,6 +753,10 @@ vips_affine_init( VipsAffine *affine )
*
* @idx, @idy, @odx, @ody default to zero.
*
* Image are normally treated as unpremultiplied, so this operation can be used
* directly on PNG images. If your images have been through vips_premultiply(),
* set @premultiplied.
*
* This operation does not change xres or yres. The image resolution needs to
* be updated by the application.
*

View File

@ -289,6 +289,7 @@ vips_resize_build( VipsObject *object )
"idx", id,
"idy", id,
"extend", VIPS_EXTEND_COPY,
"premultiplied", TRUE,
NULL ) )
return( -1 );
in = t[4];
@ -300,6 +301,7 @@ vips_resize_build( VipsObject *object )
"idx", id,
"idy", id,
"extend", VIPS_EXTEND_COPY,
"premultiplied", TRUE,
NULL ) )
return( -1 );
in = t[4];
@ -311,6 +313,7 @@ vips_resize_build( VipsObject *object )
"idx", id,
"idy", id,
"extend", VIPS_EXTEND_COPY,
"premultiplied", TRUE,
NULL ) )
return( -1 );
in = t[4];
@ -444,7 +447,10 @@ vips_resize_init( VipsResize *resize )
* This operation does not change xres or yres. The image resolution needs to
* be updated by the application.
*
* See also: vips_shrink(), vips_reduce().
* This operation does not premultiply alpha. If your image has an alpha
* channel, you should use vips_premultiply() on it first.
*
* See also: vips_premultiply(), vips_shrink(), vips_reduce().
*
* Returns: 0 on success, -1 on error
*/