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 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 # pdfium
AC_ARG_WITH([pdfium], AC_ARG_WITH([pdfium],
AS_HELP_STRING([--without-pdfium], [build without pdfium (default: test)])) 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*/ #endif /*DEBUG*/
#ifdef HAVE_HEIF_COLOR_PROFILE
/* FIXME should probably check the profile type ... lcms seems to be /* FIXME should probably check the profile type ... lcms seems to be
* able to load at least rICC and prof. * 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, vips_image_set_blob( out, VIPS_META_ICC_NAME,
(VipsCallbackFn) NULL, data, length ); (VipsCallbackFn) NULL, data, length );
} }
#endif /*HAVE_HEIF_COLOR_PROFILE*/
return( 0 ); return( 0 );
} }

View File

@ -162,6 +162,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
struct heif_error error; struct heif_error error;
struct heif_encoding_options *options; struct heif_encoding_options *options;
#ifdef HAVE_HEIF_COLOR_PROFILE
if( !save->strip && if( !save->strip &&
vips_image_get_typeof( save->ready, VIPS_META_ICC_NAME ) ) { vips_image_get_typeof( save->ready, VIPS_META_ICC_NAME ) ) {
const void *data; const void *data;
@ -184,6 +185,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
return( -1 ); return( -1 );
} }
} }
#endif /*HAVE_HEIF_COLOR_PROFILE*/
options = heif_encoding_options_alloc(); options = heif_encoding_options_alloc();
/* FIXME .. should be an option, though I don't know of any way to /* 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.file_loader("heifload", HEIC_FILE, heif_valid)
self.buffer_loader("heifload_buffer", HEIC_FILE, heif_valid) self.buffer_loader("heifload_buffer", HEIC_FILE, heif_valid)
self.save_load_buffer("heifsave_buffer", "heifload_buffer", self.save_load_buffer("heifsave_buffer", "heifload_buffer",
self.colour, 70) self.colour, 80)
self.save_load("%s.heic", self.colour) self.save_load("%s.heic", self.colour)
# test lossless mode # test lossless mode
@ -859,11 +859,13 @@ class TestForeign:
assert len(b2) > len(b1) assert len(b2) > len(b1)
# try saving an image with an ICC profile and reading it back # 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() buf = self.colour.heifsave_buffer()
im = pyvips.Image.new_from_buffer(buf, "") im = pyvips.Image.new_from_buffer(buf, "")
p1 = self.colour.get("icc-profile-data") p1 = self.colour.get("icc-profile-data")
p2 = im.get("icc-profile-data") if im.get_typeof("icc-profile-data") != 0:
assert p1 == p2 p2 = im.get("icc-profile-data")
assert p1 == p2
# add tests for exif, xmp, ipct # add tests for exif, xmp, ipct
# the exif test will need us to be able to walk the header, # the exif test will need us to be able to walk the header,