tag => { List => 'Bag', Writable => 'lang-alt' },

Started by herb, August 27, 2019, 04:05:08 AM

Previous topic - Next topic

herb

Hello Phil,

Some days ago we had a discussion whether Exiftool does support lang-alt tags with each language element being also a list.
For me the answer is YES, because I found such tags: XMP-Plus Custom1, Custom2, etc.

A)
So I populated Custom1 with command
exiftool.exe -sep ## -xmp-plus:custom1=cu1##cu2##cu3 -xmp-plus:custom1-de=de1##de2##de3 -xmp-plus:custom1-fr=fr1##fr2##fr3 test.jpg
and modified it with
exiftool.exe -sep ## -xmp-plus:custom1+=cu4 -xmp-plus:custom1-fr-=fr1 test.jpg
Then I displayed all tags with
exiftool.exe -a -g0:1 -struct -xmp:all test.jpg
and recieved
---- XMP:XMP-x ----
XMP Toolkit                     : Image::ExifTool 11.63
---- XMP:XMP-plus ----
Custom 1 (de)                   : [de1,de2,de3]
Custom 1 (fr)                   : [,fr2,fr3]
Custom 1                        : [cu1,cu2,cu3,cu4]

For me the output of Custom1-fr has an error: one comma to much.

B)
Then I played a little around adding and removing language tags. Sorry I do not remember the sequence of all used commands.
The result is the following xmp structure (a copy done with an editor):
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 11.63'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
<rdf:Description rdf:about=''
  xmlns:plus='http://ns.useplus.org/ldf/xmp/1.0/'>
  <plus:Custom1>
   <rdf:Bag>
    <rdf:li>
     <rdf:Alt>
      <rdf:li xml:lang='x-default'>cu1</rdf:li>
      <rdf:li xml:lang='x-default'>cu2</rdf:li>
      <rdf:li xml:lang='x-default'>cu3</rdf:li>
      <rdf:li xml:lang='de'>de1</rdf:li>
      <rdf:li xml:lang='fr'>fr1</rdf:li>
     </rdf:Alt>
    </rdf:li>
    <rdf:li>
     <rdf:Alt>
      <rdf:li xml:lang='de'>de2</rdf:li>
      <rdf:li xml:lang='fr'>fr2</rdf:li>
     </rdf:Alt>
    </rdf:li>
    <rdf:li>
     <rdf:Alt>
      <rdf:li xml:lang='de'>de3</rdf:li>
      <rdf:li xml:lang='fr'>fr3</rdf:li>
     </rdf:Alt>
    </rdf:li>
   </rdf:Bag>
  </plus:Custom1>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>


When I display these values, depending on using option -struct I get different output:
exiftool.exe -struct -xmp:all -g0:1 test.jpg
gives
---- XMP:XMP-plus ----
Custom 1                        : [cu3]
Custom 1 (de)                   : [de1,de2,de3]
Custom 1 (fr)                   : [fr1,fr2,fr3]


exiftool.exe -xmp:all -g0:1 test.jpg
gives
---- XMP:XMP-plus ----
Custom 1                        : cu1, cu2, cu3
Custom 1 (de)                   : de1, de2, de3
Custom 1 (fr)                   : fr1, fr2, fr3


Or in other words: In case of using option -struct not all values are displayed for custom1-x-default.

Thanks for your help in advance
Best regards
Herb

Phil Harvey

Hi Herb,

Quote from: herb on August 27, 2019, 04:05:08 AM
For me the output of Custom1-fr has an error: one comma to much.

The fr language is missing from the first entry, so the first item in the Custom1-fr list is empty.

QuoteThen I played a little around adding and removing language tags. Sorry I do not remember the sequence of all used commands.
The result is the following xmp structure (a copy done with an editor):

Ah.  I can get this by copying all tags from the file into itself.  I'll look into this.

- 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 that you will look into it.

QuoteThe fr language is missing from the first entry, so the first item in the Custom1-fr list is empty.
Yes, you might be right;
But I started with a*.jpg file that had only Exif-tags and I wrote/changed XMP-plus tags only via Exiftool. This is true for case A) and also case B).

Best regards
Herb

Phil Harvey

Right, but you deleted the first fr entry with -xmp-plus:custom1-fr-=fr1, so you should expect an empty first element in the fr list.  There is nothing wrong with this.

- 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 replies.
Now I guess I need a private lesson.

For me the tag xmp-plus:custom1 is a set of lists: custom1-x-default, custom1-de, custom1-fr, and maybe more.
And each of these lists is independent from all other lists.

So in my testcase I deleted element fr1 from list: custom1-fr, which now has only 2 elements.

When I understand you right: the lists are not independent from each other; and in my testcase the element fr1 was replaced with an "empty" element.
I think, I need more details about the behaviour of the lists.
Do I have to read the lists as a matrix: rows = number of elements; columns = "language" ?

Thanks for your help in advance.
Best regards
Herb

Phil Harvey

Hi Herb,

If you look at the XMP you will see that this is a list of items, each of which has a number of language alternatives.

The ExifTool -struct output doesn't show this very well, and may be adding to the confusion.

But ExifTool doesn't handle list of alt-lang tags very well.  I have some work to do in this area.

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

Phil Harvey

Quote from: Phil Harvey on August 27, 2019, 10:58:53 AM
ExifTool doesn't handle list of alt-lang tags very well.  I have some work to do in this area.

I've just released ExifTool 11.64 which improves handling of lists of lang-alt tags.

Thanks for pointing out this problem.

- 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 the new version with the correction. I am astonished that you could do the correction in that short time.
I just downloaded it and will test it next week.

Enjoy your holiday.

Best regards
Herb


herb

Hello Phil,

I started some test with latest version Exiftool 11.64

I populated tag custom1 with following command:
exiftool.exe -sep ## -xmp-plus:custom1=c1##c2##c3 -xmp-plus:custom1-de=de1##de2##de3 -xmp-plus:custom1-fr=f1##f2 test.jpg
Quotethis is a list of items, each of which has a number of language alternatives
This is exactly how the tag-values are stored now.

Then I displayed this tag:
exiftool.exe -xmp:all test.jpg
gives:
XMP Toolkit                     : Image::ExifTool 11.64
Custom 1                        : c1, c2, c3
Custom 1 (de)                   : de1, de2, de3
Custom 1 (fr)                   : f1, f2


exiftool.exe -xmp:all -struct test.jpg
gives
XMP Toolkit                     : Image::ExifTool 11.64
Custom 1 (fr)                   : [f1,f2]
Custom 1                        : [c1,c2,c3]
Custom 1 (de)                   : [de1,de2,de3]


The output of this command does not start with -x-default language.
I have never seen this before.
So I feel free to ask whether the above output  is ok.

Thanks in advance
Best regards
Herb

Phil Harvey

Hi Herb,

Thanks for testing this.

The order of the tags within a lang-alt list in the output is not significant.  I don't know why the default language doesn't come first, but it shouldn't matter.

- 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,

Wow, what a quick reply.
I asked, because
- for lang-alt tags my application always expects x-default language first,
- I have never seen this for lang-alt tags that are not a list,
- and I hoped that Exiftool will guarantee this sequence.

Thanks for your answer.
Best regards
Herb

Phil Harvey

Hi Herb,

OK, I'll look into why this happens.

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

Phil Harvey

Hi Herb,

ExifTool 11.65 (just released) will preserve the order of the first encountered language in a list of lang-alt lists.  This will always put the default entry first, provided that:

1. The first item in the list has an x-default entry.

and

2. The x-default entry comes before other languages (as it should, according to the XMP specification).

- 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,

You are great. Thousand times, thank you.

This time I cannot start tests before begin of next week.

Best regards
Herb

herb

Hello Phil,

I hope that this post does not kill your - hopefully very good - holiday feelings.
And sorry, that it has become a little bit long.

I did some tests with version 11.65.
My tests were so called "chicken-farm-tests" with files *.xmp which I created and/or modified. I worked with
- tag xmp-plus:custom1: this as an example for a non-structure lang-alt list and
- also a user-defined lang-alt list as an element of a structure-list.
I also worked with structure defining characters like [ { or ,

During the test I had some findings:

(1) Finding 1
exiftool.exe -sep # -xmp-plus:custom1-x-default=x1#x2#x3 -xmp-plus:custom1-de=d1#d2#d3 -xmp-plus:custom1-fr=f1#f2 test.xmp
gives the following error:
Internal error: no list index for Custom1-x-default!
The file is created and looks ok.

(2) Finding 2
With the attached file test.xmp I get different output whether using option -struct:
Test.xmp has (in principle) the following lang-alt lists:
- list1: <rdf:li xml:lang='x-default'>cu1</rdf:li>
          <rdf:li xml:lang='de'>cu4</rdf:li>
- list2: <rdf:li xml:lang='de'>cu5</rdf:li>
- list3: <rdf:li xml:lang='x-default'>cu3</rdf:li>

with command
exiftool.exe  -xmp:all -sep ? test.xmp
we get
Custom 1                  : cu1?cu3
Custom 1 (de)             : cu4?cu5


and with command
exiftool.exe  -xmp:all -sep ? -struct test.xmp
we get
Custom 1                  : [cu1,,cu3]
Custom 1 (de)             : [cu4,cu5]

Here Exiftool is very serious to show which element "is living" in which list.
For first command I had expected as output cu1??cu3

(3) Question: How does Exiftool populate the lists
During all my test I could not find out, how Exiftool really creates or modifies lists and populates it with the elements from the commandline.

exiftool.exe -sep # -xmp-plus:custom1=c1#c2#c3 test.xmp
creates a file with 3 lists: each list contains 1 x-default element.

exiftool.exe -sep # -xmp-plus:custom1-fr=f1#f2#f3 test.xmp
modifies this file; now we have 5 lists: first list with 2 items and 4 lists with only 1 item
I had expected to see still 3 lists - each with 2 elements now - because none of the 3 lists contained an element with language fr

Why are the existing lists not filled with elements that have language fr ?
I never could get existing lists filled with new elements (except for list 1) or in case of creating all with one command.

Thanks for your comments and help in advance.
Best regards
Herb

herb

Hello Phil,

Some days after my previous post I came to following additional question:

(4) Question
Is there a different behaviour of the list whether it is a Seq, Bag or Alt?

Best regards
Herb

Phil Harvey

Hi Herb,

Quote from: herb on September 19, 2019, 06:53:29 AM
(1) Finding 1
exiftool.exe -sep # -xmp-plus:custom1-x-default=x1#x2#x3 -xmp-plus:custom1-de=d1#d2#d3 -xmp-plus:custom1-fr=f1#f2 test.xmp
gives the following error:
Internal error: no list index for Custom1-x-default!

I do not get this error with the attached test.xmp file and the above command.

Quote(2) Finding 2
With the attached file test.xmp I get different output whether using option -struct:

Yes.  ExifTool doesn't generate missing list entries unless the -struct option is used.

Quote(3) Question: How does Exiftool populate the lists
During all my test I could not find out, how Exiftool really creates or modifies lists and populates it with the elements from the commandline.

This really hasn't been tightly defined because up until now nobody has really cared about this.  Most people would write the default and french entries at the same time, and wouldn't notice this quirk.  I can look into explaining/documenting and/or changing this behaviour if it is important to you.

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

Phil Harvey

Quote from: herb on September 23, 2019, 10:38:43 AM
(4) Question
Is there a different behaviour of the list whether it is a Seq, Bag or Alt?

No.

- 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 comments.

ad (1) Finding 1:
QuoteI do not get this error with the attached test.xmp file and the above command.
Yes, this happens only when the command is used to create the *.xmp file.
Sorry, that I was not clear enough.

ad (3) Question
QuoteI can look into explaining/documenting and/or changing this behaviour if it is important to you.
The main goal is/was to fully understand how Exiftool is working.
And sorry, I have to agree, it would be great when Exiftool would populate existing lists first that allow an element to be added.

Best regards
Herb

Phil Harvey

Quote from: herb on September 25, 2019, 01:30:29 PM
Yes, this happens only when the command is used to create the *.xmp file.
Sorry, that I was not clear enough.

Thanks.  I can reproduce this now.  I'll look into this.

Quotead (3) Question
QuoteI can look into explaining/documenting and/or changing this behaviour if it is important to you.
The main goal is/was to fully understand how Exiftool is working.
And sorry, I have to agree, it would be great when Exiftool would populate existing lists first that allow an element to be added.

This is a bit lower priority, but I'll look into this too if I get a chance.

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

Phil Harvey

Quote from: Phil Harvey on September 26, 2019, 07:10:38 AM
Quote from: herb on September 25, 2019, 01:30:29 PM
Yes, this happens only when the command is used to create the *.xmp file.
Sorry, that I was not clear enough.

Thanks.  I can reproduce this now.  I'll look into this.

I forgot to post back here, but this was fixed in ExifTool 11.66.

Thanks for the report.

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