Command Line Basics: View Image EXIF Data

June 15, 2011 by
Filed under: command line, HowTo, image editing, linux, Ubuntu 

I've got a huge number of digital photos on my computer that need to be organized. What I would like to do is sort the pictures by the date they were taken. The first step to sorting the pictures is to know the date they were taken. As long as the clock is properly set on your camera, your pictures should have the correct date and time of the photo stored in the image's EXIF data. You can view an image's EXIF data using the identify command.

The identify command is part of the Image Magick package. If it's not installed on your system, check your distro's repositories. In Ubuntu you can install it with:

sudo apt-get install imagemagick

Now that Image Magick is installed, you can view the EXIF data for your images.
identify -format %[exif:*] file.jpg

Now in my case I'm just interested in the date and time the picture was taken. I can view that information with this command.
identify -format %[EXIF:DateTime] file.jpg

The output looks like this.
2009:04:04 18:48:05

This means that the picture was taken at 6:48:05 PM on April 4, 2009.

Now that I can view the date, it should be possible to write a script to sort the images into folders by year and month.

Comments

2 Responses to “Command Line Basics: View Image EXIF Data”

  1. Tomek D. says:

    Using IM for reading EXIF is very slow because IM loads the whole image to read the EXIF data. Not a big problem if used with small JPGs but try to load a 20 Mpix NEF or DNG. It would take about a minute or more.

  2. Henkka says:

    If you have edited some photos, the %[EXIF:DateTime] field will probably show the date and time of last edition. In that case use %[EXIF:DateTimeOriginal], which will show the date the photo was actually taken.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>