Merge branch 'master' of github.com:libvips/libvips
This commit is contained in:
commit
8c2fff0a44
36
configure.ac
36
configure.ac
@ -927,6 +927,42 @@ if test x"$with_heif" != x"no"; then
|
||||
)
|
||||
fi
|
||||
|
||||
# heif_context_set_primary_image not in 1.1
|
||||
if test x"$with_heif" = x"yes"; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $HEIF_LIBS"
|
||||
AC_CHECK_FUNCS(heif_context_set_primary_image,[
|
||||
AC_DEFINE(HAVE_HEIF_CONTEXT_SET_PRIMARY_IMAGE,1,
|
||||
[define if you have heif_context_set_primary_image.])
|
||||
],[]
|
||||
)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
# heif_encoding_options_alloc not in 1.1
|
||||
if test x"$with_heif" = x"yes"; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $HEIF_LIBS"
|
||||
AC_CHECK_FUNCS(heif_encoding_options_alloc,[
|
||||
AC_DEFINE(HAVE_HEIF_ENCODING_OPTIONS_ALLOC,1,
|
||||
[define if you have heif_encoding_options_alloc.])
|
||||
],[]
|
||||
)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
# exif/xmp profile support not in 1.1
|
||||
if test x"$with_heif" = x"yes"; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $HEIF_LIBS"
|
||||
AC_CHECK_FUNCS(heif_context_add_exif_metadata,[
|
||||
AC_DEFINE(HAVE_HEIF_CONTEXT_ADD_EXIF_METADATA,1,
|
||||
[define if you have heif_context_add_exif_metadata.])
|
||||
],[]
|
||||
)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
# color profile support added in 1.3.3
|
||||
if test x"$with_heif" = x"yes"; then
|
||||
save_LIBS="$LIBS"
|
||||
|
@ -108,6 +108,7 @@ vips_foreign_save_heif_dispose( GObject *gobject )
|
||||
dispose( gobject );
|
||||
}
|
||||
|
||||
#ifdef HAVE_HEIF_CONTEXT_ADD_EXIF_METADATA
|
||||
typedef struct heif_error (*libheif_metadata_fn)( struct heif_context *,
|
||||
const struct heif_image_handle *,
|
||||
const void *, int );
|
||||
@ -119,10 +120,12 @@ struct _VipsForeignSaveHeifMetadata {
|
||||
{ VIPS_META_EXIF_NAME, heif_context_add_exif_metadata },
|
||||
{ VIPS_META_XMP_NAME, heif_context_add_XMP_metadata }
|
||||
};
|
||||
#endif /*HAVE_HEIF_CONTEXT_ADD_EXIF_METADATA*/
|
||||
|
||||
static int
|
||||
vips_foreign_save_heif_write_metadata( VipsForeignSaveHeif *heif )
|
||||
{
|
||||
#ifdef HAVE_HEIF_CONTEXT_ADD_EXIF_METADATA
|
||||
VipsForeignSave *save = (VipsForeignSave *) heif;
|
||||
|
||||
int i;
|
||||
@ -150,6 +153,7 @@ vips_foreign_save_heif_write_metadata( VipsForeignSaveHeif *heif )
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
#endif /*HAVE_HEIF_CONTEXT_ADD_EXIF_METADATA*/
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -187,22 +191,32 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
|
||||
}
|
||||
#endif /*HAVE_HEIF_COLOR_PROFILE*/
|
||||
|
||||
#ifdef HAVE_HEIF_ENCODING_OPTIONS_ALLOC
|
||||
options = heif_encoding_options_alloc();
|
||||
/* FIXME .. should be an option, though I don't know of any way to
|
||||
* test it
|
||||
*/
|
||||
options->save_alpha_channel = 1;
|
||||
#else /*!HAVE_HEIF_ENCODING_OPTIONS_ALLOC*/
|
||||
options = NULL;
|
||||
#endif /*HAVE_HEIF_ENCODING_OPTIONS_ALLOC*/
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "encoding ..\n" );
|
||||
#endif /*DEBUG*/
|
||||
error = heif_context_encode_image( heif->ctx,
|
||||
heif->img, heif->encoder, NULL, &heif->handle );
|
||||
heif->img, heif->encoder, options, &heif->handle );
|
||||
|
||||
#ifdef HAVE_HEIF_ENCODING_OPTIONS_ALLOC
|
||||
heif_encoding_options_free( options );
|
||||
#endif /*HAVE_HEIF_ENCODING_OPTIONS_ALLOC*/
|
||||
|
||||
if( error.code ) {
|
||||
vips__heif_error( &error );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#ifdef HAVE_HEIF_CONTEXT_SET_PRIMARY_IMAGE
|
||||
if( vips_image_get_typeof( save->ready, "heif-primary" ) ) {
|
||||
int primary;
|
||||
|
||||
@ -219,6 +233,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*HAVE_HEIF_CONTEXT_SET_PRIMARY_IMAGE*/
|
||||
|
||||
if( !save->strip &&
|
||||
vips_foreign_save_heif_write_metadata( heif ) )
|
||||
|
@ -535,14 +535,15 @@ vips__openslide_read( const char *filename, VipsImage *out,
|
||||
NULL, vips__openslide_generate, NULL, rslide, NULL ) )
|
||||
return( -1 );
|
||||
|
||||
/* Copy to out, adding a cache. Enough tiles for a complete row, plus
|
||||
* 50%.
|
||||
/* Copy to out, adding a cache. Enough tiles for two complete rows,
|
||||
* plus 50%. We need at least two rows, or we'll constantly reload
|
||||
* tiles if they cross a tile boundary.
|
||||
*/
|
||||
if( vips_tilecache( raw, &t,
|
||||
"tile_width", rslide->tile_width,
|
||||
"tile_height", rslide->tile_height,
|
||||
"max_tiles",
|
||||
(int) (1.5 * (1 + raw->Xsize / rslide->tile_width)),
|
||||
(int) (2.5 * (1 + raw->Xsize / rslide->tile_width)),
|
||||
"threaded", TRUE,
|
||||
NULL ) )
|
||||
return( -1 );
|
||||
|
@ -871,15 +871,18 @@ class TestForeign:
|
||||
# the exif test will need us to be able to walk the header,
|
||||
# we can't just check exif-data
|
||||
|
||||
# libheif 1.1 (on ubuntu 18.04, current LTS) does not support exif
|
||||
# write, so this test is commented out
|
||||
|
||||
# test that exif changes change the output of heifsave
|
||||
# first make sure we have exif support
|
||||
z = pyvips.Image.new_from_file(JPEG_FILE)
|
||||
if z.get_typeof("exif-ifd0-Orientation") != 0:
|
||||
x = self.colour.copy()
|
||||
x.set("exif-ifd0-Make", "banana")
|
||||
buf = x.heifsave_buffer()
|
||||
y = pyvips.Image.new_from_buffer(buf, "")
|
||||
assert y.get("exif-ifd0-Make").split(" ")[0] == "banana"
|
||||
#z = pyvips.Image.new_from_file(JPEG_FILE)
|
||||
#if z.get_typeof("exif-ifd0-Orientation") != 0:
|
||||
# x = self.colour.copy()
|
||||
# x.set("exif-ifd0-Make", "banana")
|
||||
# buf = x.heifsave_buffer()
|
||||
# y = pyvips.Image.new_from_buffer(buf, "")
|
||||
# assert y.get("exif-ifd0-Make").split(" ")[0] == "banana"
|
||||
|
||||
if __name__ == '__main__':
|
||||
pytest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user