Extracting Exif Data With Linux

Exchangeable image file format, or Exif, is a standard for storing information in image files. Most digital cameras, including smartphones, use Exif annotations. Some of the information stored includes exposure time, shutter speed, and F number, but more important to us is the date and time the photo was taken as well as GPS information. This information can be used to identify when and where a photo was taken, an obvious security concern.

Granted, this is relatively old news but still relevant due to the sheer number of iPhones out there and the fact that you have to explicitly decline geotagging on those devices.

In this post, I’m going to show how to retrieve this data from a photo and extract the useful information to track down when and where a photo was taken.

The first thing to do is to install exiftools. Do this with the following command.

sudo apt-get install libimage-exiftool-perl

Once that is installed, grab the picture you want to analyze. It must be in either .TIF or .JPG format or you will not be able to pull the data. Put the picture somewhere easy to remember and run this command:

exifdata -a photo.JPG

This will display all of the Exif data available. There are a few key fields to look for:

Instead of parsing through all of that information for every photo, the following command will extract all of that information we care about.

exiftool -a -make -model -DateTimeOriginal -gps:all photo.JPG

This will present the information like so.

Make : Apple
Camera Model Name : iPhone 5
Date/Time Original : 2013:06:10 13:55:46
GPS LatitudRee Ref : North
GPS Latitude : 25 deg 11' 50.2152"
GPS Longitude Ref : East
GPS Longitude : 55 deg 16' 27.2208"
GPS Altitude Ref : Above Sea Level
GPS Altitude : 835.8427653 m
GPS Time Stamp : 09:55:45.73
GPS Img Direction Ref : True North
GPS Img Direction : 5.834875116

Now this information can be taken to Google Maps/Earth and you can locate where that photo was taken within a few meters. For the sample above, this is what you should see:

google_maps_GPS

 Remediation

Luckily this is very easy to fix on the iPhone. To avoid this happening to you, go into Settings > Privacy > Location Services  and make sure the slider next to Camera is set to “OFF.” Now GPS tags will not be added to your photos. If you alread have a photo you would like to remove the geotags from, issue the following command.

exiftool -a -gps:all= /Path/To/Image.JPG