How to deal with exif stuff in Coolpix images that f-spot doesn’t like

I have a bat­tered and knack­ered old Nikon Coolpix S600 cam­era. The zoom no longer works and it can be quite cranky. It’s not sur­pris­ing as it has a tough time. It often gets car­ried on fell races and road races in, er, ‘hos­tile’ con­di­tions. Its com­pact size and ‘sports’ set­ting makes it handy for fir­ing and for­get­ting. I have a Canon com­pact that gets sim­i­lar treat­ment but on the whole the Canon can’t take the pun­ish­ment that the Nikon can.

The prob­lem I have with the Nikon is that there seems to be issues with the exif data. Whether it’s the cam­era, the camera’s firmware, or the soft­ware I use on the PC to process images, I don’t know. The upshot is the same, though, I have prob­lems writ­ing exif data back to the jpegs from the photo man­age­ment soft­ware f-spot.

I always start f-spot on the com­mand line in debug mode and save the out­put to a file. This way I can get a bet­ter idea of what’s going on. i.e.

f-spot --debug 2>&1 | tee /home/dougie/f-spot.out

(there’s a wrap­per script involved too that takes a backup of the old data­base first).

Once I have the images in f-spot I start apply­ing tags. I have f-spot con­fig­ured so that it writes tags to the image file itself as this gives me greater flex­i­bil­ity if I start copy­ing pho­tos around the place or into other pack­ages. This set­ting is in f-spot under Edit / Pref­er­ences. i.e.

write image data to file

So now I have my pho­tos and I’ve applied some tags to them. But if I have a look at the ter­mi­nal ses­sion where I started f-spot, I can see there are prob­lems. The mes­sages will typ­i­cally look some­thing like this:

[4 Debug 21:39:15.516] open uri = file:///jpegs/2011/06/11/DSCN5936.JPG
[4 Debug 21:39:15.940] Invalid thumbnail, reloading: file:///jpegs/2011/06/11/DSCN5934.JPG
[4 Debug 21:39:15.942] open uri = file:///jpegs/2011/06/11/DSCN5934.JPG
[14 Debug 21:39:15.968] Syncing metadata to file (file:///jpegs/2011/06/11/DSCN5928.JPG)...
[14 Warn 21:39:15.970] Metadata of file file:///jpegs/2011/06/11/DSCN5928.JPG may be corrupt, refusing to write to it, falling back to XMP sidecar.
[4 Debug 21:39:16.359] Invalid thumbnail, reloading: file:///jpegs/2011/06/11/DSCN5931.JPG
[4 Debug 21:39:16.360] open uri = file:///jpegs/2011/06/11/DSCN5931.JPG
[14 Debug 21:39:16.569] Syncing metadata to file (file:///jpegs/2011/06/11/DSCN5924.JPG)...
[14 Warn 21:39:16.571] Metadata of file file:///jpegs/2011/06/11/DSCN5924.JPG may be corrupt, refusing to write to it, falling back to XMP sidecar.
[4 Debug 21:39:16.786] Invalid thumbnail, reloading: file:///jpegs/2011/06/11/DSCN5928.JPG
[4 Debug 21:39:16.787] open uri = file:///jpegs/2011/06/11/DSCN5928.JPG
[14 Debug 21:39:17.153] Syncing metadata to file (file:///jpegs/2011/06/11/DSCN5914.JPG)...
[14 Warn 21:39:17.154] Metadata of file file:///jpegs/2011/06/11/DSCN5914.JPG may be corrupt, refusing to write to it, falling back to XMP sidecar.

The prob­lem for me is two-fold

  1. f-spot has a prob­lem with the meta­data in the jpeg.
  2. It’s cre­at­ing extra .xmp files that I don’t want.

I’ve tried sev­eral avenues to resolve this and I thought the fol­low­ing would do the trick:

jhead -purejpg

This uses the Linux util­ity jhead to rewrite the image header with a stan­dard one. Unfor­tu­nately the prob­lem per­sists. So I took a more bru­tal approach. I used the linux util­ity exiftool to oblit­er­ate all meta data from the image.

At first I’d copy all the images from the mem­ory card into a direc­tory and then run exiftool on all the files there. i.e.

exiftool -all= *

(Note that syn­tax; there’s a space between the equal sign and asterix)

This is fine but unfor­tu­nately it pretty much destroys any use­ful or inter­est­ing extra infor­ma­tion. Most I can live with­out, except the date and time that the photo was taken. It auto­mat­i­cally inher­its the file mod­i­fi­ca­tion time instead.

The solu­tion is to first read the jpegs into f-spot, then, while f-spot is still run­ning, go to the direc­tory where the images have been imported to, then run the exiftool com­mand there. In my setup, I have f-spot con­fig­ured to copy all imported jpegs to /jpegs where they are auto­mat­i­cally arranged in direc­to­ries accord­ing to date and time. So the pro­ce­dure for me is as follows:

  1. Import jpegs into f-spot
  2. With f-spot run­ning, change to des­ti­na­tion direc­tory where jpegs were imported to
  3. Run exiftool -all= *
  4. carry out tag­ging oper­a­tions in f-spot

The advan­tage of this is that despite oblit­er­at­ing the meta data in the files using exiftool, f-spot still knows the data and times of these pho­tos in its own data­base. So the next time you write to them with f-spot, by adding a tag for instance, they will get the date and time from f-spot. You lose pretty much every­thing else, which is a shame, but the date and time are what’s most impor­tant for me.

Typ­i­cally what I tend to do is read all the pho­tos from the mem­ory card into a tem­po­rary folder, e.g. ~dougie/in, where I can carry out a quick pass using some­thing like gee­qie to delete any truly ter­ri­ble pho­tos. Then I import the pho­tos into f-spot. Once that’s done I change to the des­ti­na­tion direc­tory where f-spot has copied the pho­tos and run exi­fool. e.g.

dougie@phoenix /jpegs/2011/06/11 $ exiftool -all= *
60 image files updated
dougie@phoenix /jpegs/2011/06/11 $

Note the syn­tax for the exiftool com­mand. That’s a space after the equal sign and before the asterix. It’s a pow­er­ful com­mand so it’s best to check the man page first to ensure that you know what it’s going to do.