The problemSometimes image metadata is mangled by the programs we use to create our images. For example, if you assemble images into a panorama and/or an HDR image, you might find that the lens metadata is deleted or corrupted, including the lens model, focal length, aperture etc. The RAW file has the correct metadata, but not the intermediary TIFF. I've even seen a few cases in my own recent work where a DNG's metadata is subtly corrupted.
If you don't care about this metadata, then none of this is a problem. However, if you like the lens information to be displayed correctly on Web services like Flickr, or you like to use the metadata browser in Lightroom, then it's helpful to fix the problem. What follows are some brief notes, for those who may be interested. I was poking around with this stuff earlier today and perhaps others will find my findings useful.
Restoring the metadataThe restoration is a low risk operation, because we are never modifying the RAW, only using it as a source. The task is to modify the TIFF or DNG, which is then used to output the web ready jpegs, or files for your clients or what have you. There are two steps:
- Where a lot of metadata is missing or is wrong, exiftool has a handy option -tagsFromFile which allows you to bulk copy metadata from one of the source RAW files into the TIFF/DNG. (If you like shooting panoramas from vertically assembled images, be sure to restore the exif orientation tag in the TIFF/DNG after the exiftool operation).
- Where the lens model is missing or wrong in Lightroom or on Flickr (e.g. you want to see EF24-105mm f/4L IS USM instead of 24.0 - 105.0 mm), the tag to add or modify is what's known as an auxiliary XMP tag, specifically the tag Lens. There are typically quite a few tags that have something to do with lens metadata, found in exif, maker notes, and XMP metadata, but for Adobe users at least, this auxiliary XMP tag Lens is the one to modify. My assumption is that Adobe creates this tag when importing the RAW. In any case, for reference info see exiftool and exiv2. You can get the correct value to insert from one of two places: if you have a recent camera that creates Exif metadata to the version 2.3 Exif specs, it's in the Lens Model. If not, try to find it in the maker notes. I use Canon and it's easy to find. I don't know about other systems.
If step 1 is necessary, then very likely step 2 is as well. In other words, step 1 is optional, but step 2 is not.
AutomationMaking these changes by hand would be mind numbingly tedious, but it's possible to automate it. I did so today by writing a Python script, and calling it from Lightroom using
Jeffrey Friedl's "Run Any Command" Lightroom Export Plugin. My python script takes one or more TIFFs or DNGs and automatically figures out the corresponding RAW files from which to copy the correct metadata, and either reads & writes the metadata directly or calls exiftool to do it. No user intervention is required, apart from asking Lightroom to read the metadata again.
I don't recommend using a solution like my Python script as a general purpose solution. It works just fine for my Canon files, workflow and programming skills. However Lightroom plugins are written in Lua, and in my case I don't see myself taking the time to write one of those. If I'm not the only one who cares about this stuff, however, one of the folks who is into writing Lightroom plugins like John Beardsworth or Jeffrey Friedl could probably rustle up something fairly quickly.
Of course someone may have already written something nice already and I just don't know about it!