make heif load/save work with 1.3.2

This commit is contained in:
John Cupitt 2019-02-20 12:30:12 +00:00
parent 8523c306fe
commit cae57d5670
4 changed files with 21 additions and 3 deletions

View File

@ -927,6 +927,18 @@ if test x"$with_heif" != x"no"; then
)
fi
# color profile support added in 1.3.3
if test x"$with_heif" = x"yes"; then
save_LIBS="$LIBS"
LIBS="$LIBS $HEIF_LIBS"
AC_CHECK_FUNCS(heif_image_handle_get_raw_color_profile,[
AC_DEFINE(HAVE_HEIF_COLOR_PROFILE,1,
[define if you have heif_image_handle_get_raw_color_profile.])
],[]
)
LIBS="$save_LIBS"
fi
# pdfium
AC_ARG_WITH([pdfium],
AS_HELP_STRING([--without-pdfium], [build without pdfium (default: test)]))

View File

@ -356,6 +356,7 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
}
#endif /*DEBUG*/
#ifdef HAVE_HEIF_COLOR_PROFILE
/* FIXME should probably check the profile type ... lcms seems to be
* able to load at least rICC and prof.
*/
@ -381,6 +382,7 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
vips_image_set_blob( out, VIPS_META_ICC_NAME,
(VipsCallbackFn) NULL, data, length );
}
#endif /*HAVE_HEIF_COLOR_PROFILE*/
return( 0 );
}

View File

@ -162,6 +162,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
struct heif_error error;
struct heif_encoding_options *options;
#ifdef HAVE_HEIF_COLOR_PROFILE
if( !save->strip &&
vips_image_get_typeof( save->ready, VIPS_META_ICC_NAME ) ) {
const void *data;
@ -184,6 +185,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
return( -1 );
}
}
#endif /*HAVE_HEIF_COLOR_PROFILE*/
options = heif_encoding_options_alloc();
/* FIXME .. should be an option, though I don't know of any way to

View File

@ -843,7 +843,7 @@ class TestForeign:
self.file_loader("heifload", HEIC_FILE, heif_valid)
self.buffer_loader("heifload_buffer", HEIC_FILE, heif_valid)
self.save_load_buffer("heifsave_buffer", "heifload_buffer",
self.colour, 70)
self.colour, 80)
self.save_load("%s.heic", self.colour)
# test lossless mode
@ -859,11 +859,13 @@ class TestForeign:
assert len(b2) > len(b1)
# try saving an image with an ICC profile and reading it back
# not all libheif have profile support, so put it in an if
buf = self.colour.heifsave_buffer()
im = pyvips.Image.new_from_buffer(buf, "")
p1 = self.colour.get("icc-profile-data")
p2 = im.get("icc-profile-data")
assert p1 == p2
if im.get_typeof("icc-profile-data") != 0:
p2 = im.get("icc-profile-data")
assert p1 == p2
# add tests for exif, xmp, ipct
# the exif test will need us to be able to walk the header,