Using the Exif tool on Linux

Read / write Exif tags to your photo collection.

Paul Bradley

In this video I am going to show you how to read and write Exif tags to and from your digital photographs. Exif is an acronym for EXchangeable Image File format, which is a standard for including metadata in certain types of files, particularly JPEG image files produced by your digital camera. This metadata can contain a lot of information like the make of your camera, but it also includes details about each photograph, like the exposure, shutter speed and whether the flash fired or not.

I have two specific examples I want to show you today. First, lets say you forgot to change your cameras internal date and time before you went on holiday, all the pictures would be taken with the wrong time stamp, so I am going to demonstrate how you can quickly modify the date and time across all your photographs by entering a timezone offset. In the second example I am going to show you how to add a copyright notice to all your photographs.

We are going to use the Exif tool developed by Phil Harvey, which is a platform independent Perl library coupled with a command line utility, which will read and write Exif tags for JPEG images. The web site contains simple instructions on how to install the software under Linux, and once installed you can start adding and modifying Exif tags to your image collection.

Here I have some photographs I took on a recent trip to France, which I am going to use for this demonstration. If I right click on an image and select properties, and then choose the image tab, you can see that my file manager lists some of the Exif tags available in the image, but not all of them.

From a terminal session, if I use Phil’s tool and type in, exif tool with the dash common switch, and enter the filename of the JPEG I want to look at, the tool will output the most common Exif tags, including image size, shutter speed, aperture, white balance and so on. However, if I use the dash capital H switch, you will see that there is a huge amount of information stored within these Exif tags.

You can also list tags from multiple image files in one go. For example, lets say we wanted to extract all the dates and times that the photographs where taken, along with their focal length and aperture settings, we would use exif tool with the dash capital T switch, to output the results in a tabbed layout. We would then specify the tags we want to extract, and use star dot JPEG, to process all the files in the current directory.

As you can see it outputs the information to the screen. This becomes very powerful as you could pipe this output into file to be processed by an external script, to insert this information into a database.

Ok, lets now try updating or writing new information back to the tags within these files. I forgot to change my cameras date before going to France, and as France is one hour ahead of us here in the UK, I need to move all these times forward by one hour. To do this I would use the exif tool, with the dash all dates switch, appending plus equals one, for one hour, and specifying all files. As you can see it returns with the message, five image files updated. If we now re-run the listing command, we can see that all the times have been moved forward by one hour. Likewise, if we had been to a country with a timezone six hours behind us, we could use minus equals six, to move the times back six hours.

To add a copyright Exif tag to all your images, you would enter dash Copyright equals, followed by your copyright message enclosed in speech marks. To verify that the tags have in fact been written to your images, you can re-run the command with no settings after the dash Copyright.

It’s worth pointing out that if you do write any changes back to your image files, the tool makes a backup copy of the original files first, which is a really nice feature.

The Exif tool is a really powerful piece of software, and I would recommend checking out the web site, as there are many examples, including how to add geo tagging information to your photographs.

About the author

Paul is a full time , specialising in creating medical software for the NHS. He can be hired to complete complex Visual Basic projects. If you would like to contact him, then please use one of the methods highlighted on the home page.

This article was first published on August 27, 2010


To keep updated with new content, you might like to subscribe to my RSS feed.