From a9b34ca3f27ed0b3c10effd3fb884936d9b02485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 5 Jun 2023 17:52:58 +0200 Subject: 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. --- tools/info.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tools/info.h') 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) { -- cgit v1.2.3