How to split metadata between EXIF and XMP

Started by Wade Tregaskis, March 03, 2024, 07:35:23 PM

Previous topic - Next topic

Wade Tregaskis

I'm trying to use exiftool to generate the EXIF & XMP blobs to go into images that I'm constructing myself in memory.  I'll be modifying those blobs a little before actually inserting them into the files, and the files don't exist on disk, so having exiftool manipulate the files directly isn't an option.

I'm able to generate the blobs just fine (i.e. `-o -.EXIF` & `-o -.XMP`), but of course I don't want their contents to overlap.  Furthermore, I want to use EXIF in preference because it's more efficient (unfortunately the file format I'm using doesn't support compression of metadata).  But of course not every possible tag is supported in EXIF, thus the need for XMP as a fallback.

I'm not sure what the best approach is.  It seems like I can:

  • Feed the full set of metadata into exiftool and have it generate the EXIF blob.
  • Feed that EXIF blob back through exiftool to figure out which tags actually made it.
  • With any of the original metadata that didn't make it into the EXIF, feed that into exiftool and have it generate the XMP blob.

It seems reasonably straightforward - unless there's caveat(s) I'm overlooking? - but is there an easier or more efficient way?

Is there a way to have exiftool generate both EXIF & XMP blobs in a single invocation?

(I'm already using -stay_open, but even so having to feed potentially huge lists of tags & values in multiple times is suboptimal)

Phil Harvey

ExifTool is able to generate EXIF and XMP simultaneously.  It will split EXIF into multiple segments if necessary either when writing tags individually or EXIF as a block.  Unfortunately XMP must be written as individual tags because the format changes when it is split between segments.

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

Wade Tregaskis

How do I have it generate EXIF & XMP in one command?  If I specify `-o -.EXIF -o -.XMP`, only the last `-o` is honoured.

I'm also not sure how I'd tell the two binary blobs apart in the output stream - is there a special delimiter used between them?

Phil Harvey

Ah, I see.  You can use -o -.exv to write both (but in the same file).  It can't be used to generate them as separate files in one command.  Actually, if you use EXV output format then the EXIF and XMP will automatically be split into segments.

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