aboutsummaryrefslogtreecommitdiff
path: root/fastiv-io.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-11 15:49:48 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-11 16:11:26 +0100
commit7e92011ab26a41a7c05fbac82753dc04e7cb4a1a (patch)
treeb05c9beba7f33ad8195fa8a29b28e7dd63acf137 /fastiv-io.c
parentac70c7724b1aa5020f358768451c08d4c77ac1ff (diff)
downloadfiv-7e92011ab26a41a7c05fbac82753dc04e7cb4a1a.tar.gz
fiv-7e92011ab26a41a7c05fbac82753dc04e7cb4a1a.tar.xz
fiv-7e92011ab26a41a7c05fbac82753dc04e7cb4a1a.zip
Extract the ICC profile and Exif data from HEIC
Diffstat (limited to 'fastiv-io.c')
-rw-r--r--fastiv-io.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/fastiv-io.c b/fastiv-io.c
index 639038b..c5cd485 100644
--- a/fastiv-io.c
+++ b/fastiv-io.c
@@ -1163,7 +1163,38 @@ load_libheif_image(struct heif_context *ctx, heif_item_id id, GError **error)
}
}
- // TODO(p): Attach any ICC color profile and Exif data.
+ heif_item_id exif_id = 0;
+ if (heif_image_handle_get_list_of_metadata_block_IDs(
+ handle, "Exif", &exif_id, 1)) {
+ size_t exif_len = heif_image_handle_get_metadata_size(handle, exif_id);
+ void *exif = g_malloc0(exif_len);
+ err = heif_image_handle_get_metadata(handle, exif_id, exif);
+ if (err.code) {
+ g_warning("%s", err.message);
+ g_free(exif);
+ } else {
+ cairo_surface_set_user_data(surface, &fastiv_io_key_exif,
+ g_bytes_new_take(exif, exif_len),
+ (cairo_destroy_func_t) g_bytes_unref);
+ }
+ }
+
+ // https://loc.gov/preservation/digital/formats/fdd/fdd000526.shtml#factors
+ if (heif_image_handle_get_color_profile_type(handle) ==
+ heif_color_profile_type_prof) {
+ size_t icc_len = heif_image_handle_get_raw_color_profile_size(handle);
+ void *icc = g_malloc0(icc_len);
+ err = heif_image_handle_get_raw_color_profile(handle, icc);
+ if (err.code) {
+ g_warning("%s", err.message);
+ g_free(icc);
+ } else {
+ cairo_surface_set_user_data(surface, &fastiv_io_key_icc,
+ g_bytes_new_take(icc, icc_len),
+ (cairo_destroy_func_t) g_bytes_unref);
+ }
+ }
+
cairo_surface_mark_dirty(surface);
fail_process: