lang-alt tag with doubled x-default entry

Started by herb, December 11, 2019, 06:17:52 AM

Previous topic - Next topic

herb

Hello Phil,

I run an application on a Windows 7 system that displays tags -  read by Exiftool -  in a GUI.
About 2 weeks ago I got a file from a friend which caused problems in my application.
Some investigations showed the problem was caused by 2 available x-default tag-entries: -xmp:rights-x-default.
As always Exiftool delivered all values of these tags properly to my application.

But as a curious developer I asked what will happen in case of a lang-alt tag inside a structure has 2 x-default values.
So I prepared a *.xmp file containing such tags.
For structure and also the xmp file please see attached zip-file.

Now I displayed the content with Exiftool inside (only one) DOS-box and got the following output:
Lines: -XMPToolkit: Image::ExifTool 1178 are removed for a better overview.
All commands have been sent immediatly one after the other and sometimes I used option -H and sometimes -D.

exiftool.exe -a -H -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
     - XMPEixmListB2                   : [{ObjectX2=1xdefault1,ObjectX2-de=german}]
     - XMPEixmListB2ObjectX2           : [1xdefault1,2xdefault2]
     - XMPEixmListB2ObjectX2           : 2xdefault2
     - XMPEixmListB2ObjectX2-de        : german

exiftool.exe -a -D -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
    - XMPEixmListB2                   : [{ObjectX2=1xdefault1,ObjectX2-de=german}]
    - XMPEixmListB2ObjectX2           : [1xdefault1,2xdefault2]
    - XMPEixmListB2ObjectX2           : 2xdefault2
    - XMPEixmListB2ObjectX2-de        : german

exiftool.exe -a -D -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
    - XMPEixmListB2                   : [{ObjectX2=2xdefault2,ObjectX2-de=german}]
    - XMPEixmListB2ObjectX2           : 1xdefault1
    - XMPEixmListB2ObjectX2-de        : german

exiftool.exe -a -H -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
     - XMPEixmListB2                   : [{ObjectX2=1xdefault1,ObjectX2-de=german}]
     - XMPEixmListB2ObjectX2           : [1xdefault1,2xdefault2]
     - XMPEixmListB2ObjectX2           : 2xdefault2
     - XMPEixmListB2ObjectX2-de        : german

exiftool.exe -a -H -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
     - XMPEixmListB2                   : [{ObjectX2=1xdefault1,ObjectX2-de=german}]
     - XMPEixmListB2ObjectX2           : [1xdefault1,2xdefault2]
     - XMPEixmListB2ObjectX2           : 2xdefault2
     - XMPEixmListB2ObjectX2-de        : german

exiftool.exe -a -H -s -api struct=2 -use mwg -u -sort -g0:2 -xmp:all test-double-xdef.xmp
---- XMP:Image ----
     - XMPEixmListB2                   : [{ObjectX2=2xdefault2,ObjectX2-de=german}]
     - XMPEixmListB2ObjectX2           : 1xdefault1
     - XMPEixmListB2ObjectX2-de        : german

As you can see in most cases the output differs from output of previous command.
This is totally unclear to me.
I also repeated this test more than once and each session gave a different but similar result.

The structured output for XMPEixmListB2 always does contain only one x-default value; but this value is not always the same.
The output of flattened tag XMPEixmListB2ObjectX2 is sometimes a list with all x-default values, sometimes it contains only 1 value and sometimes it is delivered in both formats.

For me this is very confusing.
Thanks for your help in advance
herb

Phil Harvey

Hi Herb,

I wouldn't spend too much time on this since there should never be duplicate languages in a lang-alt list.

But differing order in the output is a result of the way metadata is stored in unordered hashes internally by ExifTool.  ExifTool sorts the tags when outputting, but in this case the sort order is indeterminate, presumably because the languages are the same.  I'm not sure why one tag disappears sometimes, but I don't know if it is worth chasing this down.  And I don't think it is worthwhile adding a patch to work around this.  But it may be worthwhile adding a validation test so a warning is issued when the -validate option is used.

- 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 ($).

herb

Hello Phil,

thanks for your reply and thanks for the explanations.
On one hand you are right, so "malformed tags" are not seen very often; but on the other hand I thought - or better hoped - it can be much more easier corrected.

To enhance the validation is a very good idea.

Best regards
herb

Phil Harvey

Hi Herb,

Thanks for the suggestion.

ExifTool 11.79 will add this to the checks that are done when the -validate option is used.

- 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 ($).