I am writing a GUI wrapper in Scala/Swing for exiftool, the metadata is being displayed in 4 tabs labelled exif/iptc/xmp/gps. For extraction I use 4 invocations of exiftool:
exiftool -exif:all <file>
exiftool -iptc:all <file>
exiftool -xmp:all <file>
exiftool -gps:all <file>
I know it is inefficient but this way I get the four tag groups separately for sorting them in different tabs.
exiftool <file>
is more efficient but I would have to manually parse all tags to determine when the next tag group starts. Is there a clever way to do it with one invocation resulting with a marker (or blank line) between sections that I overlook? Or a tag that is guaranteed to be the first one in the next group?
Thanks!
Found it - the -g option is what I was looking for.
One thing to watch for is FAQ #3 (https://exiftool.org/faq.html#Q3)
QuoteWhen duplicate tags exist, only one is extracted unless the -a option is used. Beware that options like -EXIF:all select all EXIF tags from the extracted tags, so EXIF tags hidden by duplicate tags in other locations will not appear in the output for -EXIF:all. For example, the command
exiftool -gps:all image.jpg
will NOT necessarily extract all EXIF GPS tags because some may have been suppressed by same-named tags in other groups. To be sure all EXIF GPS tags are extracted, the -a option must be used:
exiftool -a -gps:all image.jpg
Example of this. The file contains both
IPTC:Headline and
XMP:Headline, as shown by the first command. The second command lists all XMP tags. The third command lists the IPTC tags, but because the
-a (
-duplicates) option (https://exiftool.org/exiftool_pod.html#a---a--duplicates---duplicates) isn't used, the
IPTC:Headline is suppressed.
C:\>exiftool -G -a -s -Headline y:\!temp\Test4.jpg
[IPTC] Headline : iptc:headline
[XMP] Headline : xmp:headline
: xmp:headline
C:\>exiftool -G1 -s -XMP:All y:\!temp\Test4.jpg
[XMP-x] XMPToolkit : Image::ExifTool 13.13
[XMP-photoshop] Headline : xmp:headline
C:\>exiftool -G1 -s -iptc:All y:\!temp\Test4.jpg
[IPTC] ApplicationRecordVersion : 4
Quote from: pejax on January 21, 2025, 04:03:47 PMIs there a clever way to do it with one invocation resulting with a marker (or blank line) between sections that I overlook? Or a tag that is guaranteed to be the first one in the next group?
You can use the
-g (
-groupHeadings) option (https://exiftool.org/exiftool_pod.html#g-NUM-:NUM...--groupHeadings)
Example:
C:\>exiftool -g -a -s y:\!temp\Test4.jpg
---- ExifTool ----
ExifToolVersion : 13.13
---- File ----
FileName : Test4.jpg
Directory : y:/!temp
FileSize : 451 kB
FileModifyDate : 2025:01:20 08:54:04-08:00
FileAccessDate : 2025:01:20 14:37:16-08:00
FileCreateDate : 2024:11:23 07:49:15-08:00
FilePermissions : -rw-rw-rw-
FileType : JPEG
FileTypeExtension : jpg
MIMEType : image/jpeg
ExifByteOrder : Big-endian (Motorola, MM)
ImageWidth : 1749
ImageHeight : 1205
EncodingProcess : Baseline DCT, Huffman coding
BitsPerSample : 8
ColorComponents : 3
YCbCrSubSampling : YCbCr4:2:0 (2 2)
---- EXIF ----
XResolution : 72
YResolution : 72
ResolutionUnit : inches
YCbCrPositioning : Centered
XPKeywords : Dad
---- XMP ----
XMPToolkit : Image::ExifTool 13.12
Subject : Dad
Cool - thanks for pointing out the -a option.