ExifTool Forum

ExifTool => Developers => Topic started by: herb on August 20, 2018, 11:20:20 AM

Title: Question to -api struct=2 for listtype tags
Post by: herb on August 20, 2018, 11:20:20 AM
Hello Phil,

I work with Exiftool v11.10 on a Windows 7 system.

In order to test structures and also string-tags with multiline content I read all tags of an image
exiftool.exe -t -G0:1 -all:all -sep ?? -api struct=2 some-other-options  image.jpg
My application starts Exiftool using the -stay_open mechanism and the "some-other-options" are out of interest for the described problem.

For listtype tags (in my case -by-linetitle) I have the following problem:
- only in case of -by-linetitle has > 1 elements, all elements are inside brackets []
  which are used when also structures are output.
- in case of -by-linetitle has only 1 element, its value is sent without brackets:
QuoteIPTC \t by-linetitle \t [title1

I had expected that also this one element is inside brackets: [[title1].

Now my question: How to differ between:
- the first bracket [ is part of tag value
- the first bracket is because of -api struct=2 for a listtype tag   

Is this an error?
Thanks for your help in advance

Best regards
Herb
Title: Re: Question to -api struct=2 for listtype tags
Post by: Phil Harvey on August 20, 2018, 11:35:57 AM
Hi Herb,

I can't reproduce the wayward leading "[":

> exiftool a.jpg -by-linetitle=a
    1 image files updated
> exiftool a.jpg -t -s -G0:1 -by-linetitle -sep '??' -api struct=2
IPTC By-lineTitle a
> exiftool a.jpg -by-linetitle+=b
    1 image files updated
> exiftool a.jpg -t -s -G0:1 -by-linetitle -sep '??' -api struct=2
IPTC By-lineTitle [a,b]


But yes, IPTC list-type tags with only a single value won't be in square brackets.  Currently this is only done for XMP tags.  The Struct option is really designed only for XMP, but it does have some spill-over as you discovered.  I suppose I could also apply this to other metadata types, but I worry about backward compatbility so I wouldn't be making such a significant change just before an anticipated production release.

- Phil
Title: Re: Question to -api struct=2 for listtype tags
Post by: Phil Harvey on August 20, 2018, 11:39:54 AM
Ah.  I see.  Your question is how to distinguish a list from a single item in square brackets in the Struct output:

> exiftool a.jpg -by-linetitle='[a,b]'
    1 image files updated
> exiftool a.jpg -by-linetitle -sep '??'
By-line Title                   : [a,b]
> exiftool a.jpg -t -s -G0:1 -by-linetitle -sep '??' -api struct=2
IPTC By-lineTitle [a,b]    <== THIS
> exiftool a.jpg -by-linetitle=a -by-linetitle=b
    1 image files updated
> exiftool a.jpg -by-linetitle -sep '??'
By-line Title                   : a??b
> exiftool a.jpg -t -s -G0:1 -by-linetitle -sep '??' -api struct=2
IPTC By-lineTitle [a,b]    <== IS THE SAME AS THIS


  Good question.  Let me think...
Title: Re: Question to -api struct=2 for listtype tags
Post by: Phil Harvey on August 20, 2018, 11:50:31 AM
Actually, I would probably recommend using either -j or -X instead of -t for your output format, and dropping the -sep option.  With -j for example, this is the difference:

  "IPTC:By-lineTitle": "[a,b]"

vs.

  "IPTC:By-lineTitle": ["a","b"]

and with -X:

<IPTC:By-lineTitle>[a,b]</IPTC:By-lineTitle>

vs.

<IPTC:By-lineTitle>
  <rdf:Bag>
   <rdf:li>a</rdf:li>
   <rdf:li>b</rdf:li>
  </rdf:Bag>
</IPTC:By-lineTitle>


- Phil
Title: Re: Question to -api struct=2 for listtype tags
Post by: herb on August 20, 2018, 12:12:02 PM
Hello Phil,

thanks for your quick reply.
Yes you are right, for XMP listtype tags also one element is sent inside brackets.

Thanks also for your hints how to solve this problem, but currently my application is not able to parse json or xml output.

Best regards
Herb
Title: Re: Question to -api struct=2 for listtype tags
Post by: Phil Harvey on August 20, 2018, 12:13:03 PM
Just FYI:  I tried implementing this for other tag types and it resulted in failure of 32 of the 509 tests in the test suite.  So it could have a significant impact on other developers using ExifTool.

Parsing JSON is quite straightforward and may be worth the effort.

- Phil