From 3bdffd03dbe71ace5986a65e04997676e7d5ace4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Sun, 28 May 2023 11:04:18 +0200 Subject: [PATCH] tools: decode TIFF XMP fields as UTF-8 This is more space-efficient than an array of ASCII codepoints. Perhaps more fields would make good use of specialized decoders, just this one made listings particularly annoying to deal with, and it may additionaly contain important metadata. --- tools/info.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/info.h b/tools/info.h index 699e434..0d7a699 100644 --- a/tools/info.h +++ b/tools/info.h @@ -176,6 +176,7 @@ static jv parse_exif_entry(jv o, const struct tiffer *T, struct tiffer_entry *entry, const struct tiff_entry *info) { + const struct tiff_entry *info_begin = info; static struct tiff_entry empty[] = {{}}; if (!info) info = empty; @@ -200,6 +201,9 @@ parse_exif_entry(jv o, const struct tiffer *T, struct tiffer_entry *entry, } else if (entry->type == TIFFER_UNDEFINED && !info->values) { // Several Exif entries of UNDEFINED type contain single-byte numbers. v = parse_exif_undefined(entry); + } else if (info_begin == tiff_entries && entry->tag == TIFF_XMP && + (entry->type == TIFFER_UNDEFINED || entry->type == TIFFER_BYTE)) { + v = jv_string_sized((const char *) entry->p, entry->remaining_count); } else if (tiffer_real(T, entry, &real)) { v = jv_array(); do v = jv_array_append(v, parse_exif_value(info->values, real));