Fixing messed-up metadata with exiftool

Posted on

Just a quick jot to spread the solution to a problem I was having.

I’m really enjoying using Darktable software to process my raw camera files when I’m not happy with the in-camera JPEG. It does happen, usually if the white balance is off or I’ve messed up the exposure, and to me this makes it worth shooting both raw and JPEG, even though it means I store thousands of huge raw files I’ll never actually use. (Aside: if Digikam starts allowing me to treat both the raw and the JPEG as the same picture for the purposes of tagging and rating, it’ll become much more efficient to remove unneeded files.)

I have a BASH script that does various things to my processed photos to prepare them for the web, including resizing with ImageMagick and writing artist info with ExifTool. ExifTool doesn’t like the JPEGs produced by Darktable from my Nikon D90’s NEF files, complaining:

Error: [minor] Bad GPS directory - mypic.jpg
0 image files updated
1 files weren't updated due to errors

I believe this is a manifestation of this known Darktable bug (apparently persisting in v0.9.1).

Just running exiftool -m [...] to tell ExifTool to ignore minor errors doesn’t get it past this error. The solution for me has been to get ExifTool to delete and rewrite the metadata, which is addressed in Question 20 in the ExifTool FAQs. So now I include the line

exiftool -all= -tagsfromfile @ -all:all -unsafe bad.jpg

before my next exiftool command, with the understanding that I may lose some metadata by doing this. I can always get it all back, if I want to, from the original photo file, which I never delete.

Really, it took me longer than it should have to find this, so I’m putting this up as a breadcrumb for sleep-deprived Googlers. Incidentally, my trail to the solution went via this forum thread where someone else with a D90 was having trouble with mangled metadata after processing photos with Picasa 3.8. Edit: I should point out that the forum post was answered helpfully by Phil Harvey, the author of ExifTool, himself, and that ExifTool is available for Linux, Windows, and Mac OS X. Good stuff.