Tags are exported to IPTC:Keywords as a single concatenated string
Describe the bug
Export of $(TAGS) into Iptc.Application2.Keywords gets saved as a single keyword although every keyword must be stored on its own. The tags are exported as a concatenated string with the (darktable) separator "comma" instead of exporting an unordered array like the XMP and IPTC definitions demand.
To Reproduce In the "edit metadata exportation" dialog (from the "export selected" tool) add a new "per metadata setting":
- redefined tag:
Iptc.Application2.Keywords - formula:
$(TAGS)
export image.
Expected behavior
If checking the relevant section the two tags "hello" and "world" should be output as separate words:
hello and world
But instead they are concatenated with a comma:
hello,world
One can use exiftool to check this, but be careful, exiftool also uses a comma to separate the real keywords. So the difference is very subtle and only a space.
_$ exiftool -IPTC:Keywords sample.jpg
If one looks at the hexdump of the file, the separation between keywords can be seen much better by the control characters present in the file.
Platform (please complete the following information):
- Darktable Version: 3.2.1
- OS: BunsenLabs Lithium (debian 10)
Additional context A lot of applications translate the tags/keywords after reading the "unordered array" (XMP standard definition) through their own string manipulation and split all of the keywords at commas. This makes this bug hard to detect but even more impactful in software that respects the individual keywords and does not simplify.
Officially the comma is only a separator for the user interface, it is not part of the standard and is not stored in the file. In theory - although no really useful in practical life - a tag/keyword could contain a comma. Tags/keywords like "Smith, PhD" or numbers with a comma as a decimal separator are in theory possible. (darktable not being able to handle that on import is a whole different bug altogether.)
Thanks for reporting. I'll try to fix this.
Expected behavior If checking the relevant section the two tags "hello" and "world" should be output as separate words:
helloandworldBut instead they are concatenated with a comma:hello,world
I've tried to find some "rules" related to that without success. Could you pinpoint any reference about this ? Unlike XMP with "XmpBag" or "XmpSeq" (Exiv2) which are managed as lists, IPTC fields are typed as "String" (Exiv2). That's why, in that case I've left the commas to describe the list.
I'm opened to make the change if we can find some related rules. As you said this may bring other issues with tags or other piece of information containing commas. That would imply significant changes to manage properly all these cases. However we may have to get there...
I've tried to find some "rules" related to that without success. Could you pinpoint any reference about this ?
Not sure if this is what you were looking for: https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#keywords
If you download the reference image from https://iptc.org/standards/photo-metadata/iptc-standard/ eog shows the XMP-IPTC dc:subject fields as array:

Thanks for the references.
- For true iptc (not xmp.iptc), this is a pure text, and it seems there is nothing telling the separator should be a space instead of the comma (the opposite neither). So to make safely a change on this we would need to find some explicite rules.

- For xmp.iptc.xxxx, that is an other story. And if you use those should work as you expect (if xmpbag):

I see. Honestly I have the feeling my knowledge about meta data and specifically the standard is not enough to fully grasp all the details. I was e.g. assuming that xmp.iptc is the way how the IPTC meta data is stored in the file and wasn't aware, that there's another way ("true iptc" as you stated). Looking at the above linked standard the only hint I saw is
Basic Specs | Data type: Text / Cardinality: 0..unbounded
which means according to https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#the-specification-template that the tag is allowed to appear zero to arbitrary times. This would IMHO suggest to not use one tag to enter all key words concatenated by a separator character (e.g. comma), but to use a separate tag for each key word. But as I said, only IMHO. :) I fear I'm not of additional help here (and might not have understood the problem in the first place completely enough anyway...).
the tag is allowed to appear zero to arbitrary times. This would IMHO suggest to not use one tag to enter all key words concatenated by a separator character (e.g. comma), but to use a separate tag for each key word.
Thanks for your explanation, I think I understand now. I've given a look at iptc importation code in dt, and this tells me you are right. I'll give a try.
@grubernd , @sjjh It would be great if one of you could check if #7475 solves the issue as expected. Thanks in advance.