Hack Your Exif Data from the Command Line: Five Fun Uses for Exiftool

It happens every time you press the shutter.  Tiny circuits spring into action and furiously record the information from every sensor pixel onto your memory card.  But pixel information is not all that is recorded.  With every shutter press, your camera records dozens of interesting details about how the photo was taken.  These details are tucked away deep inside the labyrinth of code that comprises your photo file.  Photo editing softwares, such as Photoshop or Lightroom, can unlock some of this data for viewing later. But they normally only scratch the surface of the available information by displaying only the most commonly used exif tags.

To mine the deepest depths of your exif data, you may want to try a utility called Exiftool. This utility is known for its ability to squeeze every last drop of information from your exif data. Don’t expect a slick, graphical interface, though. Although there are more user friendly softwares which incorporate the Exiftool engine, we’re going to demonstrate Exiftool where it is at its minimalist best – at the command line.

Exiftool was written by Phil Harvey, an amateur photographer who spends his day hours as a nuclear physicist at the Sudbury Neutrino Observatory at Queen’s University. When he saw that his software, originally written to catalog scientific images, was useful for all types of photographs, he elected to freely distribute the open source code to the public. A physicist-photographer-programmer who gives his work away free – this guy has some serious geek cred!

So shut down that fancy graphical interface, pop open a command line, and pretend you’re hacking into the Matrix. Neo is waiting.

Installation

Windows and Mac OS X installation packages and installation instructions are available here. Working with Exiftool does require some basic knowledge of the command line – either the Windows DOS command prompt or the traditional UNIX command line in Mac OS X.  We won’t rehash the basics here but there are plenty of tutorials throughout the web which address this. If you decide this is too deep for you, don’t worry. Just remember the tool is there if you ever want to come back to it.

Exiftool Projects to Try

Once Exiftool is installed, here are five exercises which should give you some idea of what you can accomplish with this tool.

1. Navigate to your photos directory and run the Exiftool command line utility on one of your raw photo files.  Just enter the command below and then marvel at the stream of data that is extracted. Raw files will be much more interesting to examine since much of their information can be stripped during jpeg conversion.

exiftool -a -u -g1 filename

2. Since the first exercise likely generated many pages of information, try exporting the data to a text file for a more careful examination.

exiftool -a -u -g1 filename > exifoutput.txt

3. Examining a single photo file is a good way to learn what snippets of information are stored in your raw photo files. Once you find a particular parameter of interest, you can then exploit it using Exiftool’s multi-file processing option.  The command below parses an entire directory of images (including subdirectories), extracts the focal length of each image, and writes it to a tabulated text file.

exiftool -T -r -lens -focallength directory > exifoutput.txt

Once all this information is compiled, you are just a spreadsheet away from a complete data analysis of your photography habits. The graph below shows the focal length used for each of the 4,000 images taken with a 28-135mm lens.

 4. A similar query can also be constructed to show your shutter speed habits.

exiftool -T -r -lens -shutterspeed directory > exifoutput.txt

The graph below shows the shutter speed used for each of the 40,000 photos taken with a Canon 7D.

5. If you looked hard enough in exercise 2, you may have noticed a particular parameter that caught your interest.  For the Canon 7D, an intriguing snippet of information recorded with each photo is the camera temperature. Should your camera also capture this, simply run the following query:

exiftool -T -r -lens -cameratemperature directory > exifoutput.txt

Then you can prove to your friends just how cold it was that day you photographed the snow storm of the century.

These are only a few of the many ways Exiftool can be used to mine your photo data.  How much practical value is there in such an intense analysis of your photos? Debatable. But in the true spirit of geek adventure, we don’t do things because they are practical – we do things because we can.

Get More Camera Technica Greatness:

Subscribe to this Feed ◊ Follow us on Twitter ◊ Visit Our Google+ Page ◊ Follow Us On Facebook ◊ Email Us

Comments

  1. I’ve been using this great tool for years as part of my film archival workflow. I scan to 16biy uncompressed tif then run files through a script that uses exifrool to add copyright, name, date captured, camera make, camera type, focal length etc. seems like over kill but it’s nice have field notes rolled into scanned file data forever.

  2. I’ve been using exiftool for a while and its great. Always learn something new with it. For example your graphs! Would love it if you shared how you made the graphs. I put the output of the exiftool in excel, but my graphs don’t look anything like yours. Any quick tips?

    • Preston Scott says:

      Hi Pat,
      You may need to break out some formatting tricks to get the data in the right form to plot. For instance, query number 3 above should give you a column of focal lengths, but they may be formatted with “mm” on the end which Excel does not recognize as a number to plot. Use a function like =left(b1,3) to chop the mm off the end. Once you get a column that Excel recognizes as numbers, try the countif function to count the number of occurrences of a particular focal length. For instance, =countif(B:B,”<40″) will count the number of focal lengths less than 40 in column B. You can then manually build a plot that is to your liking.
      Thanks for the interest and I hope that helps!
      Preston

      • Phil Harvey says:

        … you could also use the exiftool -n option to return the numerical value (avoiding the “mm” suffix on the FocalLength)

        • Preston Scott says:

          Great tip Phil.
          Thanks for stopping by and thanks for creating this great tool! It sounds like you definitely have some fans.
          Preston

  3. I just came across exiftool this week to fix a bunch of pictures that had the time off by one hour. Phil’s exiftool was able to fix this easily. Once the image times were fixed from that particular camera, I could drop the images from multiple cameras onto a Better Finder Rename droplet and rename them all to have a common prefix followed by a sequence number. Everything was in chronological order thanks to exiftool.

    THANKS Phil Harvey!

  4. Why is every other EXIF tool run on a GUI a lot less extensive? When are these calls and functions going to be turned into something that can be mouse clicked? Do you need some help converting this into javascript or C++ Mr. Harvey or is it better off as a mystery to the mouse?

    • Phil Harvey says:

      I don’t think it is possible to build all of ExifTool’s functionality into a GUI. The GUI is just too restrictive. That having been said, there is an ExifToolGUI available for Windows that supports some basic functions.