Unified output from both .jpg and associated .xmp file?

Started by stuporglue, May 20, 2023, 04:05:35 PM

Previous topic - Next topic

stuporglue

I want to read exif data from both a jpg file and the corresponding xmp file, if it exists.

For the purposes of my script I know that the xmp file is always the same name as the jpg file, with xmp at the end (example.jpg and example.xmp).

Right now I have to run exiftool on the jpg file and the xmp separately and combine the metadata programatically. With how nicely exiftool works for everything else I feel like I must be missing some option to unify the output.

My use case is that I have configured Digikam to write all metadata changes to xmp files and I keep the jpg files as read-only. So the jpg has all the original metadata, the xmp has additions I have done in digikam (like face tagging, 90 degree rotations).

In order to get all metadata I have to run exiftool on both. Any suggestions about if there's a better way to get all the metadata would be appreciated.

$ exiftool -ver
12.57
$ exiftool -a -G1  DSC_0512_2.JPG
# original metadata from camera appears here
$ exiftool -a -G1  DSC_0512_2.JPG.xmp
# modified and new metadata from digikam appears here

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

stuporglue

Thanks, Phil. I might just need to adjust how I'm thinking about this.

The command you gave does extract the data from both file, but the output is presented as metadata from two files.

======== IMG_1692.JPG
[ExifTool]      ExifTool Version Number         : 12.57
[System]        File Name                       : IMG_1692.JPG
[System]        Directory                       : .
[System]        File Size                       : 2.1 MB

...more output...
======== IMG_1692.JPG.xmp
[ExifTool]      ExifTool Version Number         : 12.57
[System]        File Name                       : IMG_1692.JPG.xmp
[System]        Directory                       : .
[System]        File Size                       : 2.4 kB
...more output...

In my mind I have been thinking of it all as metadata belonging to the image in IMG_1692.JPG and assumed that there should be a consolidated view showing all metadata about IMG_1692.JPG. From the output it seems that this may not be the correct mental model.

StarGeek

No, they are two separate files. Digital Asset Management (DAM) program will treat them as one file, but the XMP sidecar is a separate file.

How were you planning to reconcile the data if there was a conflict?  For example, if the Description in the jpg had a value of "Description one" and the Description in the XMP file had a value of "Description two", you would have to have a way of choosing one over the other.

The Metadata Sidecar Files page gives some examples of copy data between the original file and the sidecar, if you wanted to sync them up before hand.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

stuporglue

QuoteHow were you planning to reconcile the data if there was a conflict?

Honestly I'm kind of still winging it. 🙃

I'm making a home photo library webpage so my wife can sort our photos by date, location and tagged people.

For my next todo item, I'm looking for all people tags, so I will build a list from all tag names and add them to the database. I will save a unique list per file, so if the name is present in both the JPG and XMP it will only show up once.

To determine the date of the photo I'm looking at all date fields available and choosing the oldest date. For geo location I would take from the XMP if available, otherwise from the JPG, otherwise leave it blank.

I'm just storing all the exif data in a database so I don't have to read all my files for future features.

Originally I was writing all my metadata back to the files (with a GUI tool, not with exiftool). I had a crash mid-write that corrupted a few photos so I started saving all new metadata to XMP files and not touching the JPGs. I realized a few weeks ago that my photo import script (which uses exiftool) wasn't automatically pulling data from the XMP files and started looking at how to get at the new tags.


As far as my question goes, I appreciate your and Phil's quick responses. I'll have to think about how to handle the data, but I better understand how exiftool works.