ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: banana123 on February 14, 2024, 10:35:47 AM

Title: How to detect thumbnail image segment and value as hex
Post by: banana123 on February 14, 2024, 10:35:47 AM
Hi

Is there any way to detect thumbnail image segment?

For example - one thumbnail image is at APP1 as part of the EXIF data and another image is part of APP13 as part of photoshop data?

And another question - is there any way to get the value for each metadata field as hex / binary?

Thanks!
Title: Re: How to detect thumbnail image segment and value as hex
Post by: StarGeek on February 14, 2024, 11:23:17 AM
Quote from: banana123 on February 14, 2024, 10:35:47 AMFor example - one thumbnail image is at APP1 as part of the EXIF data and another image is part of APP13 as part of photoshop data?

I think they have different names.  ThumbnailImage in the EXIF group and PhotoshopThumbnail in the Photoshop group.  But I don't have PS to be able to check.

QuoteAnd another question - is there any way to get the value for each metadata field as hex / binary?

There's the -b (-binary) option (https://exiftool.org/exiftool_pod.html#b---b--binary---binary) to get the raw data from a tag like the thumbnails, but it won't be separated from any other tag you extract.

Adding the -X (-xmlFormat) option (https://exiftool.org/exiftool_pod.html#X--xmlFormat) or -j (-json) option (https://exiftool.org/exiftool_pod.html#j-JSONFILE--json) will give you the binary data in Base64.  The -php option (https://exiftool.org/exiftool_pod.html#php) will encode any non-printable characters in hex.

Another option would be to use something like this (taken from StackOverflow) (https://stackoverflow.com/a/56184271/3525475)
s/(.)/sprintf '%04x', ord $1/seg
and use the -api Filter option (https://exiftool.org/ExifTool.html#Filter) (note that this would be global, affecting all extracted tags)
-api "Filter=s/(.)/sprintf '%04x', ord $1/seg"
or the -p (-printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat) on individual tags
-p "${ThumbnailImage;s/(.)/sprintf '%04x', ord $1/seg"

I haven't tested these last two, so they may require some fixing.
Title: Re: How to detect thumbnail image segment and value as hex
Post by: Phil Harvey on February 14, 2024, 03:36:08 PM
Quote from: StarGeek on February 14, 2024, 11:23:17 AMThere's the -b (-binary) option (https://exiftool.org/exiftool_pod.html#b---b--binary---binary) to get the raw data from a tag like the thumbnails, but it won't be separated from any other tag you extract.

...unless you use the -W (capital "W") output option with %t (tag name) or %c (copy number) in the file name string.

- Phil