Read & Remove EXIF Data From the Command Line

Most digital cameras will insert metadata into images. This metadata is stored using the exchangeable image file format (EXIF) and can contain camera specifications, exposure settings, thumbnails, GPS coordinates and more. This article outlines some Linux command line tools you can use for reading, editing and removing EXIF metadata from images.

Reading and Editing EXIF Metadata with ExifTool

ExifTool is powerful a Perl program that can be used to read and edit EXIF metadata in images. To install ExifTool as /usr/bin/exiftool on Fedora, install the perl-Image-ExifTool package:

su -c 'yum install perl-Image-ExifTool'

Alternatively, you can use CPAN to install ExifTool in /usr/local/bin/exiftool.

su -c "perl -MCPAN -e'install Image::ExifTool'"

After installation, you will have the exiftool command available in /usr/bin or /usr/local/bin. To view the EXIF metadata in an image, just past the image as an argument to exiftool.

exiftool dsc_0790.jpg

Here is a snippet of the output from the above command:

ExifTool Version Number         : 7.60
File Name                       : dsc_0790.jpg
Directory                       : .
File Size                       : 4.4 MB
File Modification Date/Time     : 2008:07:16 09:45:20-07:00
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : NIKON CORPORATION
Camera Model Name               : NIKON D200
Orientation                     : Horizontal (normal)
X Resolution                    : 300
Y Resolution                    : 300
Resolution Unit                 : inches
Software                        : Bibble 4.10a
Modify Date                     : 2007:06:23 22:00:14
Exposure Time                   : 1/40
F Number                        : 2.0
Exposure Program                : Aperture-priority AE
ISO                             : 100

ExifTool has many options for editing and removing EXIF metadata in images. To see the available options, use the –help switch or read the ExifTool documentation.

exiftool --help

Reading EXIF Metadata with Jhead

Jhead is a command line tool for displaying EXIF data embedded in JPEG images. On Fedora, use Yum to install Jhead:

su -c 'yum install jhead'

Now, use /usr/bin/jhead to read EXIF metadata:

jhead dsc_0790.jpg

Here is an example of the output produced by the jhead command:

File name    : dsc_0790.jpg
File size    : 4654488 bytes
File date    : 2008:07:16 09:45:20
Camera model : NIKON D200
Date/Time    : 2007:06:23 22:00:14
Resolution   : 3880 x 2608
Flash used   : No
Focal length : 50.0mm  (35mm equivalent: 75mm)
Exposure time: 0.025 s  (1/40)
Aperture     : f/2.0
ISO equiv.   : 100
Exposure bias: 1.00
Whitebalance : Auto
Exposure     : aperture priority (semi-auto)
GPS Latitude : ? ?
GPS Longitude: ? ?
======= IPTC data: =======
(C)Flag       : 0
DateCreated   : 20070623
Time Created  : 220014
Record vers.  : 4

Removing EXIF Metadata with ImageMagick

If you need to strip the EXIF metadata from images, use ImageMagick’s mogrify command. To install ImageMagick on Fedora, use Yum:

su -c 'yum install ImageMagick'

After ImageMagick is installed, you will have /usr/bin/mogrify available. The mogrify command can be used to strip Exif data from images.

mogrify -strip imagename.jpg

If you need to process a large number of files, use find and xargs:

find ./folder_of_images -name '*.jpg' | xargs mogrify -strip