aboutsummaryrefslogtreecommitdiff
path: root/tools/info.h
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-05 17:52:58 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-05 18:11:37 +0200
commita9b34ca3f27ed0b3c10effd3fb884936d9b02485 (patch)
tree43d0eb0996573481cd88558b9d4e20008aa0413f /tools/info.h
parentbd92ad73ec995da9e2b2ca57faf011290f329d53 (diff)
downloadfiv-a9b34ca3f27ed0b3c10effd3fb884936d9b02485.tar.gz
fiv-a9b34ca3f27ed0b3c10effd3fb884936d9b02485.tar.xz
fiv-a9b34ca3f27ed0b3c10effd3fb884936d9b02485.zip
Unite most info tools into just one binary
Turn this into more of an fq alternative, when used with jq. Also don't say that TIFF files are Exif.
Diffstat (limited to 'tools/info.h')
-rw-r--r--tools/info.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/info.h b/tools/info.h
index 0d7a699..d640f35 100644
--- a/tools/info.h
+++ b/tools/info.h
@@ -278,6 +278,25 @@ parse_exif(jv o, const uint8_t *p, size_t len)
return o;
}
+static bool
+detect_tiff(const uint8_t *p, size_t len)
+{
+ return tiffer_init(&(struct tiffer) {}, p, len);
+}
+
+// TODO(p): Photoshop data and ICC profiles also have their tag in TIFF,
+// they're not currently processed.
+static jv
+parse_tiff(jv o, const uint8_t *p, size_t len)
+{
+ struct tiffer T = {};
+ if (!tiffer_init(&T, p, len))
+ return add_warning(o, "invalid TIFF");
+ while (tiffer_next_ifd(&T))
+ o = add_to_subarray(o, "TIFF", parse_exif_ifd(&T, tiff_entries));
+ return o;
+}
+
// --- Photoshop Image Resources -----------------------------------------------
// Adobe XMP Specification Part 3: Storage in Files, 2020/1, 1.1.3 + 3.1.3
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
@@ -1084,6 +1103,12 @@ parse_marker(uint8_t marker, const uint8_t *p, const uint8_t *end,
return p;
}
+static bool
+detect_jpeg(const uint8_t *p, size_t len)
+{
+ return len >= 2 && p[0] == 0xff && p[1] == SOI;
+}
+
static jv
parse_jpeg(jv o, const uint8_t *p, size_t len)
{