From b3bc4811720d5d17e6a4d06fc7a328df23645c42 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Mon, 5 Jun 2023 11:03:34 +0200 Subject: rawinfo: descend into JPEG thumbnails --- tools/rawinfo.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/rawinfo.c b/tools/rawinfo.c index fa36bba..122486f 100644 --- a/tools/rawinfo.c +++ b/tools/rawinfo.c @@ -91,11 +91,20 @@ parse_raw(jv o, const uint8_t *p, size_t len) break; } - thumbnails = jv_array_append(thumbnails, - JV_OBJECT(jv_string("width"), jv_number(item->twidth), - jv_string("height"), jv_number(item->theight), - jv_string("flip"), jv_number(item->tflip), - jv_string("format"), jv_string(format))); + jv to = JV_OBJECT( + jv_string("width"), jv_number(item->twidth), + jv_string("height"), jv_number(item->theight), + jv_string("flip"), jv_number(item->tflip), + jv_string("format"), jv_string(format)); + + if (item->tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG && + item->toffset > 0 && + (size_t) item->toffset + item->tlength <= len) { + to = jv_set(to, jv_string("JPEG"), + parse_jpeg(jv_object(), p + item->toffset, item->tlength)); + } + + thumbnails = jv_array_append(thumbnails, to); } libraw_close(iprc); -- cgit v1.2.3-70-g09d2