ImageMagick is a suite of tools for Linux which allows you to manipulate images from the command line. The “
convert” command allows you to perform image conversions and image transformations; however, there are several other tools included in the suite, some of which allow you to work with the Exif data in JPEG photos.
Your Linux distribution probably has ImageMagick already installed, but if it doesn’t, you can add it on Ubuntu, Debian and Raspbian using:
On RPM based distributions you can use:
Exchangeable image file format (Exif) data is often inserted into JPEG images made by digital cameras and smartphones. This data includes information about the photo including the date and time when it was taken, what settings the camera used and even the GPS location of where the photograph was taken.
To view some basic information about the image, use ImageMagick’s “
Unfortunately, the resulting output won’t tell you much beyond the filename, its dimensions and the filesize.
To see more, use the “
Now we have the opposite problem; there is too much output!
You can use “
grep” to find just the Exif data:
You can find an individual Exif field by specifying it as part of the “
The output will be just the make of the camera which took the photo, e.g. Canon.
You can search for multiple fields at once using the “
\|” operator in grep. So to search for the date, the make of camera, the camera model, file size, the number of megapixels and information about the flash use:
You might be wondering what “exif:Flash: 16” means. This field can have several different values and is made up of a set of flags where different bits in the number indicate the status of the flash. Bit 0 indicates the flash firing status (1 means fired), bits 1 and 2 indicate if there was any strobe return light detected, bits 3 and 4 indicate the flash mode, bit 5 indicates whether the flash function is present, and bit 6 indicates “red eye” mode. 16 in binary form is 001000 which means flash didn’t fire + strobe return detection not available + flash suppressed. Or in other words, the flash didn’t fire and couldn’t anyway since it was closed/switched off.
The full list of values is as follows:
Although having the make and model of your camera embedded into the photos probably isn’t much of a privacy problem, having the GPS location of where the photo was taken certainly can be.
At the end of 2012, John McAfee – famous for starting the McAfee anti-virus company – went on the run after the murder of his neighbor in Belize. He fled to Guatemala but gave an exclusive interview to reporters working for Vice. Unfortunately McAfee was photographed by one of the reporters using a smartphone that stored the GPS information in the Exif data. When the photo was subsequently uploaded to the Internet, his location was revealed and he was later arrested. Additionally, the recent documents leaked by Edward Snowden show that the NSA analyses photos to extract their Exif data.
As a result, it is sometimes useful to remove all the Exif data from a JPEG. This can be done using ImageMagick’s “
mogrify” tool. To remove the data, use:
Now run “
identify -verbose” against the image, and you will notice that all the Exif data has been removed.
If you have any questions about the commands, please ask in the comments below.