Changing dates in your holiday pictures (fixing EXIF dates)

I went for three weeks in holidays and forgot to change the date and time on my camera. The camera stores the information in an EXIF header in the file. So, the pictures appear to be taken at the wrong date and I want to fix this with simple open tools.

Installing ExifTool

After a quick search, it seems the tool to use is exiftool. You can install it on linux using sudo apt-get install libimage-exiftool-perl. For installing exiftool on other operating systems, it seems ok.

Finding the time difference

At some point during my holidays, I anticipated the problem, so I took a picture (with my phone) of the clock of my old camera. Let's call this picture phone.jpg. I also took a picture just after, with camera; let's call it old.jpg. If you haven't or if your camera does not show its clock easily, it is not a problem, just find a picture for which you can put a date on it (and do the correct subtraction below).

So, I looked at the EXIF info of my phone, with exiftool and using grep to filter the results. We should see two dates, the date I copied the images on my drive, and the date the photo was taken (that's the one we are interested in).

$ exiftool old.jpg | grep 2015
 
File Modification Date/Time     : 2015:05:23 17:20:31+02:00
File Access Date/Time           : 2015:05:23 17:20:42+02:00
File Inode Change Date/Time     : 2015:05:23 17:20:31+02:00
Modify Date                     : 2015:02:19 22:46:13         <<<<---------
Date/Time Original              : 2015:02:19 22:46:13
Create Date                     : 2015:02:19 22:46:13

Now I need the actual (local) time the photo has been taken. For this I will use the phone.jpg but you could find another way.

$ exiftool phone.jpg | grep 2015
 
File Modification Date/Time     : 2015:05:23 17:18:54+02:00
File Access Date/Time           : 2015:05:23 17:21:00+02:00
File Inode Change Date/Time     : 2015:05:23 17:18:54+02:00
GPS Date Stamp                  : 2015:02:19
Create Date                     : 2015:02:19 10:39:13          <<<<---------
Date/Time Original              : 2015:02:19 10:39:13
GPS Date/Time                   : 2015:02:19 20:39:13Z
Create Date                     : 2015:02:19 10:39:13.851298
Date/Time Original              : 2015:02:19 10:39:13.851298

So we see the photo was taken on the 2015-02-19 at 10:39:13 but was labeled by the camera as 22:46:13. It means that, to correct the camera dates, we need to subtract 12 hours and 7 minutes. Before going forward, I double checked this difference by looking at other pictures.

Finding what fields to update

We have seen that there are multiple fields containing the same date in the EXIF. We want to list them and find their exact name (by default, exiftool pretty-prints them). For this, we will use some options of exiftool and also keep only the field containing the time of interest (22:46:13).

$ exiftool -s old.jpg | grep 2015 | grep 22:46
 
ModifyDate                      : 2015:02:19 22:46:13
DateTimeOriginal                : 2015:02:19 22:46:13
CreateDate                      : 2015:02:19 22:46:13

That's it, we need to update three fields: ModifyDate, DateTimeOriginal, CreateDate.

Applying the offset to all images in a folder

The exiftool program works recursively on folders and allow for easy time offseting. As a result, our final command takes only one line (to subtract 12 hours and 7 minutes):

$ exiftool "-ModifyDate-=12:07:00" "-DateTimeOriginal-=12:07:00" "-CreateDate-=12:07:00" -overwrite_original hawaii/
 
    1 directories scanned
  187 image files updated

The -overwrite_original option tells exiftool not to make a backup copy of your images (if like me you don't have much disk space. That's why you should double check your date offset, and test you command on a single file (a working copy) from your collection. For example, I used:

$ exiftool -s test.jpg |grep 2015
$ exiftool "-ModifyDate-=12:07:00" test.jpg
$ exiftool -s test.jpg |grep 2015
$ exiftool "-DateTimeOriginal-=12:07:00" "-CreateDate-=12:07:00" test.jpg
$ exiftool -s test.jpg |grep 2015

I hope this helps!

Any feedback or remarks? Contact me at click-me ;-p @nospam.com.