Fix EXIF dates and times with Jhead

Modifying the EXIF data in photos is pretty easy – a lot of image viewing / editing apps will let you do this, but usually only on a one by one basis. That’s a lot of pain for when you need to work with a whole lot of photos, and of no use at all from the command line. A quick Google search turned up a selection of apps that looked like they would do the job but I settled on Jhead because it works from the command line and it is available from Ubuntu’s standard repositories. There are also Windows and OS X binaries available.

Installing Jhead

Jhead’s been around for over a decade so if you’re using Linux, it’s most likely in your distro’s repositories. For Windows and OS X you can download it from here. It’s also available from Mac Ports on OS X, and probably via Homebrew too.

On Ubuntu, installing Jhead is as easy as:-

sudoapt-get install jhead

sudo apt-get install jhead

Modifying the EXIF Date and Time

Firstly, you need to work out how much time you need to adjust your photo’s EXIF data by in order to correct them. Because the photos I was working with came from two different cameras, each with a different date and time set, I separated them in to two directories and did this for each.

A full summary of Jhead’s command line arguments can be found here but for most purposes there are only two options we need to make use of, one for adjusting the time by a specified offset and one for adjusting the date.

To adjust the time, we use the -ta option followed (without space) by the offset to use in hh:mm or hh:mm:ss format. If, for example, your photo’s times are set 1 hour too far in to the future, we can subtract a single hour from all photos using the following.

jhead -ta-1:00 *.jpg

jhead -ta-1:00 *.jpg

If the photos were set 12 hours, 20 minutes and 43 seconds too far in the past, we’d offset with a positive value.

jhead -ta+12:20:43*.jpg

jhead -ta+12:20:43 *.jpg

For offsets greater than 24 hours, we can use the -da option followed by two dates in yyyy:mm:dd format, or to include a time, as yyyy:mm:dd/hh:mm:ss. Because years and months have different numbers of days, rather than specifying an offset, we actually specify two dates for this option – the first being the date to translate to, relative to the second.

So if a particular photo was taken on the 29th February 2012 at 8:21am, but the camera recorded it as the 1st January 2000 at 2:24pm, we would use the following.

jhead -da2012:02:29/08:21-2000:01:01/14:24*.jpg

jhead -da2012:02:29/08:21-2000:01:01/14:24 *.jpg

It doesn’t matter that the photos weren’t all taken at the very same time specified by either date in this argument, Jhead will just work out the correct offset to use from the before and after dates and apply it correctly to each photo individually.

Setting the File System’s Timestamp

This is not strictly necessary but can be useful if you want your file system’s file creation dates to now match those of the newly fixed EXIF dates.

jhead -ft*.jpg

jhead -ft *.jpg

Additonal Options

Jhead can also perform some other useful tasks such as image rotation in accordance with the image’s orientation tag, extracting camera settings, displaying embedded GPS info, etc. Check out it’s full list of command line options to learn more.