From a9b34ca3f27ed0b3c10effd3fb884936d9b02485 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch 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/jpeginfo.c | 80 -------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 tools/jpeginfo.c (limited to 'tools/jpeginfo.c') diff --git a/tools/jpeginfo.c b/tools/jpeginfo.c deleted file mode 100644 index 2793764..0000000 --- a/tools/jpeginfo.c +++ /dev/null @@ -1,80 +0,0 @@ -// -// jpeginfo.c: acquire information about JPEG files in JSON format -// -// Copyright (c) 2021, Přemysl Eric Janouch -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#include "info.h" - -#include - -#include -#include -#include -#include - -static jv -do_file(const char *filename, jv o) -{ - const char *err = NULL; - FILE *fp = fopen(filename, "rb"); - if (!fp) { - err = strerror(errno); - goto error; - } - - uint8_t *data = NULL, buf[256 << 10]; - size_t n, len = 0; - while ((n = fread(buf, sizeof *buf, sizeof buf / sizeof *buf, fp))) { - data = realloc(data, len + n); - memcpy(data + len, buf, n); - len += n; - } - if (ferror(fp)) { - err = strerror(errno); - goto error_read; - } - -#if 0 - // Not sure if I want to ensure their existence... - o = jv_object_set(o, jv_string("info"), jv_array()); - o = jv_object_set(o, jv_string("warnings"), jv_array()); -#endif - - o = parse_jpeg(o, data, len); -error_read: - fclose(fp); - free(data); -error: - if (err) - o = add_error(o, err); - return o; -} - -int -main(int argc, char *argv[]) -{ - // XXX: Can't use `xargs -P0`, there's a risk of non-atomic writes. - // Usage: find . -iname *.png -print0 | xargs -0 ./pnginfo - for (int i = 1; i < argc; i++) { - const char *filename = argv[i]; - - jv o = jv_object(); - o = jv_object_set(o, jv_string("filename"), jv_string(filename)); - o = do_file(filename, o); - jv_dumpf(o, stdout, 0 /* Might consider JV_PRINT_SORTED. */); - fputc('\n', stdout); - } - return 0; -} -- cgit v1.2.3-70-g09d2