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.
This commit is contained in:
Přemysl Eric Janouch 2023-05-28 11:04:18 +02:00
parent a710692725
commit 3bdffd03db
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 4 additions and 0 deletions

View File

@ -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));