Read and write XMP files directly without an image file?

Started by Joanna Carter, May 27, 2021, 04:44:40 AM

Previous topic - Next topic

Joanna Carter

Simply, is it possible using ExifTool, or do I have to resort to parsing/writing the file in code?

StarGeek

"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

Joanna Carter

OK. I've managed to sort out reading the XMP files using code - it's simpler than I thought and just requires parsing the file.

The bit in this particular jigsaw I still have to do is to write the metadata from the image file to an XMP file (and that is easy enough) but I also want to add the url of the source file at the same time, if that is possible.

Do you know if I can do that in one command? Something like...

exiftool -xmp:source="~/Pictures/_HLN0032.NEF" -xmp -b _HLN0032.NEF > _HLN0032.xmp

... or am I going to have to add the source tag to the XMP file in a separate command?

The ultimate aim is to have the source URL only in the XMP file

Phil Harvey

Hi Joanna,

Read and write operations must be performed in separate commands.

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

Joanna Carter

Thanks for your help StarGeek and Phil

I've now got my app to read and write from/to XMP files for RAW images and directly from/to the image files for other types.

For image files, I use macOS's own metadata stuff to read everything except the -rating tag, which is not available via that route and for which I use ExifTool.

I use a homegrown parser to read XMP files - it's faster and, unlike ExifTool, it's synchronous and I alreadyhave enough asynchronous code to tame for getting the actual image thumbnails loaded.

Then it suddenly dawned on me that I could use exactly the same ExifTool command line for writing to XMP files as I do for image files. Just added a small condition that, if the image is RAW, I change the file extension to .xmp

Phil, it's taken me a load of brain ache to finally understand how ExifTool works in this regard but, now the penny has dropped, it only took me an hour or so to rewrite a few lines of code in my ExifTool swift wrapper and all is happy in the world.

Thank you once again for a superb framework. My only beef is that the documentation maybe comprehensive but it is sometimes not easy to find what you want  ;)

Phil Harvey

Quote from: Joanna Carter on May 28, 2021, 11:59:25 AM
the documentation maybe comprehensive but it is sometimes not easy to find what you want  ;)

I agree.  Much of my usefulness in the forum is as an index into the documentation. ;)

But I fear that making a comprehensive index is not possible.  Google will already do much better than I could.

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

greybeard

Quote from: Joanna Carter on May 28, 2021, 11:59:25 AM

For image files, I use macOS's own metadata stuff to read everything except the -rating tag, which is not available via that route and for which I use ExifTool.


Have you managed to get any of the maker specific metadata using Apple's framework? I have been looking exclusively at Fujifilm metadata and gave up. Not to mention that Apple doesn't support Fujifilm compressed raw so isn't able to provide anything at all for those files.