Multiple tag "words" written as single tag problem

Started by I3ordo, April 04, 2022, 07:07:52 AM

Previous topic - Next topic

I3ordo

 Hi,
As i mentioned earlier, a friend is helping me with a utility that writes information jpg files with the help of exiff tool, we are now able to correctly write tags to jpgs but
Current problem is tags come out as single tag.

we are sending "zonca; ego; sconce;" to exiff tool and they appear as a single entry.
"zonca; ego; sconce;"
where they should come out as  three separate tags
zonca
ego
sconce.
I have searched this and ;
This post, the -sep argument https://exiftool.org/forum/index.php?topic=9054.0
"exiftool -sep ", " '-Keywords<Subject' '-Subject<Subject' file.jpg" keeps key words+subject  as separate entries

there are many entries about separate tags but maybe i missed the one i am looking for.
Maybe we should send "zonca ego sconce" instead or "zonca, ego, sconce"...?

Joanna Carter

I don't know why you are adding all those quotes and why you are bothering to write anything to the `Keywords` tag.

All you need, for most uses is to simply write the words to the `xmp-dc:subject`tag.

exiftool -sep ',' -subject='zonca,ego,sconce' file.jpg


I3ordo

#2
Correct! exiftool -sep ',' -subject='zonca,ego,sconce' file.jpg still writes three tags so thats great and actually there should not be any ' at all, or it will result in tags like 'zonca
ego
sconce'
which would make the "zonca key word unreachable as it would require the ' to make the "zonca" reachable at least for picasa as it ignores mid-words


Using this  exiftool -sep ',' -subject=zonca,ego,sconce file.jpg sucessfully comes out as three tags  in picasa 3.2



"and why you are bothering to write anything to the `Keywords` tag."
Writing to tags is due to being able to remove tags when necessary and since picasa is my "go-to" image browser...
If i did write the words to somewhere else, they would be only editable through browsing to the file and right clicking details etc.

actually using exiftool.exe -sep ";" -subject=zonca;ego;sconce is the best solution for me as all tags appear separate both in picasa and windows, whereas using the "," would make them separate only for picasa but not windows explorer.




StarGeek

You need to read FAQ #17.

The XPKeywords tag you were originally writing to is not a list type tag but a semicolon separated string.  A list type tag will keep each keyword separate internally.  See this post which shows the raw XMP in the case of XMP:Subject.  The keywords "one" and "two" are completely separate.  Many programs will display a list of keywords as comma separated string, but that is just the interface.

With regards to the extra quotes, you need to be aware of what quoting mechanisms your shell is using.  Mac/Linux (which I think Joanna is using) can use either double or single quotes to encapsulate tag assignments, but single quotes are recommended because there are circumstances where double quotes will change the meaning of the quoted text, mostly in cases where there is a dollar sign.

I believe Windows Powershell is similar but it has a host of other problems, such as corrupting binary data and incorrectly parsing commands.  For example, in this image, PS treats "-csv=herbier_for_exif" and "txt" as two separate parameters, not as a single parameter, as shown by the highlighting colors.

For Windows CMD, you need to use double quotes around anything that needs to be quoted.  As that is what I use, nearly all my examples will have double quotes.

Now in the case of your example.  You can add keywords to your files in multiple ways.  They can be added individually.  I'm also showing multple ways of quoting in Windows CMD
exiftool -Subject=zonca -Subject="ego" "-Subject=sconce" /path/to/files/

They can be added in one assignment, but would require using the -sep option
exiftool -sep "," -Subject="zonca,ego,sconce" /path/to/files/

Note that you can using anything as the separator
exiftool -sep "BANANA" -Subject="zoncaBANANAegoBANANAsconce" /path/to/files/

The important thing to take note of is that all of the above removes any preexisting keywords.  Only what you add in this command will be the resulting keywords.  If you want to add new keywords and keep the old ones, you have to use +=.  For example
C:\>exiftool -P -overwrite_original -Subject="Original Keyword" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Original Keyword

C:\>exiftool -P -overwrite_original -Subject+="New Keyword" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Original Keyword, New Keyword

C:\>exiftool -G1 -a -s -Subject -sep "BANANA" y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Original KeywordBANANANew Keyword


In the last example, I use the -Sep option to show that the keywords are actually separate.

Exiftool will not do any bookkeeping on keywords and will happily add the same keyword multiple times if you tell it to.
C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Original Keyword, New Keyword

C:\>exiftool -P -overwrite_original -Subject+="Original Keyword" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Subject y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Original Keyword, New Keyword, Original Keyword


With regards to what tag to use, Keywords is an older tag, part of the IPTC IIM standard.  You can use it but you also need to be aware of it's limitations.  According to the standard, there are character limits on how big an entry can be.  For example, if for some reason you want a really long Keyword, the standard says that it can be no longer that 64 characters, which can be a problem in some cases, such as this place (85 character).  Now, this character length is ignored by nearly every program that can read IPTC IIM, but by default exiftool will honor the standard and truncate any data that is too long.  This can be overridden by the -m (-ignoreMinorErrors) option.

The XMP standard is much newer and doesn't have a lot of the limitations of the older standard.  Additionally, it is easily expandable if you can't find a proper location for a piece of data you want to save, though that location will not be read by most software.

In the case of Picasa, it will read data from both the IPTC:Keywords and XMP:Subject.  If there are differences between the two, it will combine both lists.  Though Picasa does have a bad behavior with regards to keywords in either location.  If the keyword includes a comma, e.g. "Smith, John", then Picasa will incorrectly treat this as two separate keywords, "Smith" and "John".
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

I3ordo

  About the character limit; the limit is for the keyword itself right? so i can place 65 separate words with each word max 63 characters? That's what i got from this.
"there are character limits on how big an entry can be.  For example, if for some reason you want a really long Keyword, the standard says that it can be no longer that 64 characters"

btw after your post while it was quite a workout for my graphic based processor, my ideal usage scenario is in wipe mode and using " for each word just incase...
exiftool.exe -sep ";" -subject+="keyword1";"key word 2" dest.jpg

StarGeek

Quote from: I3ordo on April 04, 2022, 01:28:27 PM
  About the character limit; the limit is for the keyword itself right? so i can place 65 separate words with each word max 63 characters?

Yes, the keyword itself.  See the IPTC tags page.  For Keywords, it can be from 0 to 64 characters.  The 65th character would be trucated by default.

Example
C:\>exiftool -P -overwrite_original -keywords="1234567890123456789012345678901234567890123456789012345678901234567890" y:\!temp\Test4.jpg
Warning: [Minor] IPTC:Keywords exceeds length limit (truncated) - y:/!temp/Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -keywords y:\!temp\Test4.jpg
[IPTC]          Keywords                        : 1234567890123456789012345678901234567890123456789012345678901234


Adding the -m (-ignoreMinorErrors) option allows the limit to be ignored.  Most programs, such as Lightroom, will ignore the limit
C:\>exiftool -P -overwrite_original -m -keywords="1234567890123456789012345678901234567890123456789012345678901234567890" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -keywords y:\!temp\Test4.jpg
[IPTC]          Keywords                        : 1234567890123456789012345678901234567890123456789012345678901234567890


Quoteexiftool.exe -sep ";" -subject+="keyword1";"key word 2" dest.jpg

Don't break up the options with quotes.  Put them around the whole thing when needed otherwise you may get unexpected results.
exiftool -sep ";" -subject+="Keyword 1;Keyword 2"

Note that the -sep option is two separate parameters.  You can't put quotes around both.  Using "-sep ;" would be incorrect.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype