Merging metadata from image and XMP sidecar

Started by lokatz, November 12, 2022, 03:26:23 PM

Previous topic - Next topic

lokatz

Got a rather unusual request:  I need to merge metadata from sidecar files with metadata from RAW images and write the resulting set to a non-RAW (JPG, PNG, whatever).  Am I guessing (and reading the XMP metadata info) right that ExifTool offers no direct way of doing this?

(I know this sounds rather, well, unusual, but post-processing software from different makers being as inconsistent as it is, I ran into issues where RAW images would contain one set of keywords and the sidecar another one, for example, such that both needed to be merged.  Also, rating and label info sometimes sits in the RAW and sometimes in the sidecar, whereas the destination needs to receive it from either.)

As an indirect way of doing this, I thought about taking the sidecar route by first creating or updating a sidecar from the RAW file and then writing the merged sidecar info to the non-RAW.  Problem there is that if I interpret
exiftool -tagsfromfile SRC.EXT DST.xmpcorrectly, it overwrites information that has the same tag, rather than appending it. 

StarGeek

You can have multiple -TagsFromFile options, so you could use something like

exiftool -TagsFromFile file1.jpg -xmp:all -TagsFromFile file2.jpg -xmp:all file3.jpg

Quote from: lokatz on November 12, 2022, 03:26:23 PMAs an indirect way of doing this, I thought about taking the sidecar route by first creating or updating a sidecar from the RAW file and then writing the merged sidecar info to the non-RAW.  Problem there is that if I interpret
exiftool -tagsfromfile SRC.EXT DST.xmpcorrectly, it overwrites information that has the same tag, rather than appending it.

The problem here is how you are going to combine tags.

In the case of list type tags such as keywords, you would use the -AddTagsFromFile options, which is listed under the above link with more details under FAQ #17.  You would have to deal with duplicates afterwards with something like the NoDups helper function.

How do you want to deal with text, such as Description.  Exiftool cannot compare the text from one file to see if it is the same as another, so you might end up with the same text being repeated.

What about ratings and labels as you mention?  These are things you can't combine, so you have to prioritize one over the other.

Then comes the problem of what groups you are copying.  XMP sidecars can only hold XMP data.  Did you want to copy EXIF or IPTC data into the XMP?

A lot of this depends upon what tags you want to copy.  Trying to copy all tags runs into a lot of conflicts.

I'm not saying exiftool can't do this, it's just there is a lot of things to work out.
"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

lokatz

Sounds like what I expected: I'll probably have to write the merge method myself.  I have already done that for a few, such as rating/label/keywords/GPS, but was hoping I wouldn't have to do it for the whole set.

-AddTagsFromFile might be helpful here - hadn't considered that one yet.  Thanks.

QuoteWhat about ratings and labels?
Sorry this wasn't clear from my initial question: if one file has it and the other doesn't, that's easy to determine.  Otherwise, I'll have to set either as having priority.

QuoteXMP sidecars can only hold XMP data.  Did you want to copy EXIF or IPTC data into the XMP?
Yes, that's the plan.  Several editors do this, for instance all Adobe ones.  Are you saying ExifTool doesn't have a way of doing it?  (I did not try this yet...)


Phil Harvey

When copying EXIF and IPTC metadata into an XMP file the best you can do is to map the EXIF/IPTC tags into corresponding XMP tags.  There are a set of argfiles included in the full ExifTool distribution which do these mappings (see exif2xmp.args and iptc2xmp.args).

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

StarGeek

Quote from: lokatz on November 13, 2022, 07:47:18 AM
QuoteXMP sidecars can only hold XMP data.  Did you want to copy EXIF or IPTC data into the XMP?
Yes, that's the plan.  Several editors do this, for instance all Adobe ones.  Are you saying ExifTool doesn't have a way of doing it?  (I did not try this yet...)

No program has the ability to write EXIF or IPTC IIM data in an XMP sidecar.  As Phil says, they write to the corresponding tags, which don't always have the same name.  For example, EXIF:Copyright is copied to XMP-dc:Rights, EXIF:Artist is copied to XMP-dc:Creator.

I would suggest not copying all EXIF data into an XMP sidecar.  It can be extensive and most programs are going to read the EXIF directly from the file instead of a XMP sidecar.
"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

lokatz

Thank you both.  I guess I'm going to read out sidecar and RAW image, merge the metadata in my program, then write the results to the non-RAW version(s) of the image.  No way to automate this.