Variables · Functions · Interpolation · Brace expansions · Loops · Conditional execution · Command substitution · One-page guide to Bash scripting
Source: Bash scripting cheatsheet
A few years back when I got my GPS, I was very happy to be able to geotag my photos. However, I didn’t realize how much my camera time was desynchronising until I noticed that some pictures were not correctly mapped at all because the camera was losing a few minutes every week.
After that, I was setting the camera time when I was going out, except when I forgot, which happened almost every time. And since I became an active member on OpenStreetMap, I started taking pictures of every useful object I could find on my way, I had to find other options to keep my photos up to date in order to map them correctly.
I quickly realised that the easiest way would be to take a picture of the time in order to correct it. Based on this photo, I can correct the time of all the photos of my shooting session because it contains an image of the correct time from the GPS and the camera metadata that include the camera time, which is retrievable using exiftoolÂ or exiv2 on a UNIX system, or many other tools on Windows and Mac (ViewNX2, GPSPhotoLinker, etc.). Here’s the command line to get the data from exiftool:
exiftool -s -SubSecDateTimeOriginal DSC_9117.JPG SubSecDateTimeOriginal : 2013:02:16 21:25:47.80
Based on that, we can see a difference of 41 seconds between the metadata and the GPS time (precision is about more or less one second), where the camera is in advance.
We can now correct the picture time, using exiv2:
exiv2 -a -00:00:41 DSC_9117.JPGÂ exiftool -s -SubSecDateTimeOriginal DSC_9117.JPGÂ SubSecDateTimeOriginal : 2013:02:16 21:25:06.80
Time is now matching the GPS time, so I can apply the exiv2 command to the other photos.
Note: I use the UTC time zone in both my camera and GPS so I don’t have to worry or set local time on both devices. If the time zones are different, some additional correction may be wanted.
During my last holiday, some people saw me correcting the time of my photos by 8 seconds and really thought I was a nerd because it would make not much difference, but I like it when it’s precise 😉