Get all tags for the several groups

Started by hvdwolf, December 23, 2013, 11:11:38 AM

Previous topic - Next topic

hvdwolf

Hi,

I'm thinking of adding a tab to my program with a dropdown for the several groups which dynamically generates a matrix with dropdowns to add all possible tags for exif, xmp, iptc, makernotes, etc. as far as exiftool supports them. I know that especially xmp is extendable and is being extended and so are the makernotes.
So I'd like to know how I can get all the the tags for say exif or xmp that the exiftool version being used, supports for writing.

I have been playing with the -g and -G options like exiftool -G0 -s2 image.jpg
and tried multiple combinations of the -g[NUM][:NUM...] (-groupHeadings) and -G[NUM][:NUM...] (-groupNames).
However, that lists the tags inside the image and I want to be able to use the complete list of exif or xmp (for that exiftool version) tags to be able to add that to that images of selection of images because they are missing and you want to add them.
I already have a tab where users can define their own exiftool tags but this requires you to know the exact tag names.

If I do a -listg0 or a -listg1 I simply don't understand what I really get. For example EXIF, IPTC, XMP and MakerNotes do occur in both g0 and g1. g1 simply seems to be longer.
I also tried -listx in several combinations.

I "simply" want to get a list of the supported tags for a group that are writable(!) so that I can present a matrix with dropdown values if a person wants to add e.g. exif data.
I'm thinking of a list like you present on e.g. https://exiftool.org/TagNames/EXIF.html
or like the list you get with exiftool -G0 -s2 image.jpg, but then complete.

I checked other posts as well but it's not clear to me. Sorry if I overlook something obvious.
See my jExifToolGUI cross-platform java application (Website, Releases, Changelog) for Phil's marvelous exiftool.

Phil Harvey

Quote from: hvdwolf on December 23, 2013, 11:11:38 AM
So I'd like to know how I can get all the the tags for say exif or xmp that the exiftool version being used, supports for writing.

exiftool -listw -exif:all

and

exiftool -listw -xmp:all

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

hvdwolf

I didn't think of combining listw with the group:all, but upon searching the documentation it's even clearly explained.
So thanks a lot for your answer and sorry that I obviously didn't look carefully enough.
However, the listw command doesn't tell me the datatype.
I already came up with something like exiftool -listx -exif:all | grep "tag id" | grep "writable='true'" and parse that. I can't use this in my program though (on linux/Mac OS X I can, but not directly on Windows) but python comes with an xml parser so I'm now thinking of using that and extracting the tags that are writable, but never used xml before (time to learn something new).

I simply hoped for something more simple.
See my jExifToolGUI cross-platform java application (Website, Releases, Changelog) for Phil's marvelous exiftool.

hvdwolf

I solved it. The xml parsing is quite simple. The only "challenge" was the sequential use of tables inside the list which is a second level.

See some example code below. Of course this is only to show how to access it from python. In my program I wil "catch" the exiftool output directly and feed it into my program.

#!/usr/bin/python

import sys
import xml.etree.ElementTree as ET

# xml files created with
# exiftool -listx -gps:all > gps.xml
# exiftool -listx -exif:all > exif.xml
# exiftool -listx -xmp:all > xmp.xml
# etc.

#tree = ET.parse('gps.xml')
tree = ET.parse('exif.xml')
root = tree.getroot()

for child in root:  # The child is the table inside the xml
   for tags in child.iter('tag'):
      tag_name = tags.get('name')
      tag_type = tags.get('type')
      tag_writable = tags.get('writable')
      if tag_writable == 'true' and tag_type <> 'undef':
                   print("name: " + tag_name + "; type: " + tag_type)


And this gives me:
name: InteropIndex; type: string
name: ProcessingSoftware; type: string
name: SubfileType; type: int32u
name: OldSubfileType; type: int16u
name: ImageWidth; type: int32u
name: ImageHeight; type: int32u
<snip>
See my jExifToolGUI cross-platform java application (Website, Releases, Changelog) for Phil's marvelous exiftool.

Phil Harvey

Great.  Glad you found a solution, and thanks for posting the sample code.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).