Convert extracted JSON metadata to XMP file without involving image file

Started by aocolitii, January 14, 2019, 01:41:28 PM

Previous topic - Next topic

aocolitii

Hi Phil/Guys,

Thank you for this wonderful tool.
It's really super helpful.

This is the command that I am executing in order to get metadata in JSON format:
exiftool -j -g a.jpg > meta.json

This one is for getting metadata in XMP format:
exiftool -xmp -b a.jpg > meta.xmp

Use case: I want to store metadata as JSON, but provide a possibility to get a standalone XMP file upon request.
The first thing that comes to mind: use JSON in order to update a copy of image file and extract XMP file after the update.

Is it possible to convert JSON metadata that was extracted by using exiftool to xmp format without updating the image itself?
Some sort of "metadata convert" operation.

Thank you.

Phil Harvey

You can do this to extract XMP along with the other metadata in the JSON file:

exiftool -j -g -all -xmp -b a.jpg > meta.json

You can then extract or copy the xmp from the JSON file using the tag name "XmpXMP".

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

aocolitii

Hi Phil,

Thank you for the quick reply.

I  see. This is cool.

What if JSON part will be updated over the time and user will request XMP after these updates?

For example, the data was corrupted by the application that created this metadata.
The user will fix the metadata values by updating JSON and will ask for an XMP file.

Now I have to sync up both parts: JSON and "XmpXMP" manually.

I was thinking about a simple workflow:

1) Get JSON from file
2) Let users update values
3) Generate XMP upon request

Thank you.




Phil Harvey

You can generate XMP directly from JSON by using -G1 instead of -g and changing the SourceFile entry in the json file to the name of the xmp file or "*":

exiftool -j -G1 a.jpg > meta.json

then edit meta.json to change the SourceFile to "a.xmp", then

exiftool -j=meta.json a.xmp

Note that this will only write XMP tags that are writable by ExifTool.

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