aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-04 06:31:24 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-04 06:52:25 +0100
commit4d9236336cdd59b4dc7d933e50ef51a62eff3b72 (patch)
tree65b22ab182aed757a580e65980b91d2be9d7efa1 /tools
parent4cbf9239ee7f39f6511fc0ef0faaa70e79871c1d (diff)
downloadfiv-4d9236336cdd59b4dc7d933e50ef51a62eff3b72.tar.gz
fiv-4d9236336cdd59b4dc7d933e50ef51a62eff3b72.tar.xz
fiv-4d9236336cdd59b4dc7d933e50ef51a62eff3b72.zip
jpeginfo: parse TIFF UNDEFINED values
Diffstat (limited to 'tools')
-rw-r--r--tools/jpeginfo.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/jpeginfo.c b/tools/jpeginfo.c
index ea2218f..e4e9a67 100644
--- a/tools/jpeginfo.c
+++ b/tools/jpeginfo.c
@@ -602,6 +602,20 @@ parse_exif_ascii(struct tiffer_entry *entry)
}
static jv
+parse_exif_undefined(struct tiffer_entry *entry)
+{
+ const char *alphabet = "0123456789abcdef";
+ char *buf = calloc(1, 2 * entry->remaining_count + 1);
+ for (uint32_t i = 0; i < entry->remaining_count; i++) {
+ buf[2 * i + 0] = alphabet[entry->p[i] >> 4];
+ buf[2 * i + 1] = alphabet[entry->p[i] & 0xF];
+ }
+ jv s = jv_string(buf);
+ free(buf);
+ return s;
+}
+
+static jv
parse_exif_entry(jv o, struct tiffer *T, struct tiffer_entry *entry)
{
jv value = jv_true();
@@ -613,11 +627,13 @@ parse_exif_entry(jv o, struct tiffer *T, struct tiffer_entry *entry)
value = parse_exif_subifds(T, entry);
} else if (entry->type == ASCII) {
value = parse_exif_ascii(entry);
+ } else if (entry->type == UNDEFINED) {
+ value = parse_exif_undefined(entry);
} else if ((numeric = tiffer_real(T, entry, &real))) {
value = jv_number(real);
}
- // TODO(p): Decode UNDEFINED as a hex dump, and iterate over all values.
+ // TODO(p): Iterate over all numeric values.
for (const struct tiff_entry *p = tiff_entries; p->name; p++) {
if (p->tag != entry->tag)
continue;