Putorius
Linux Quick Tips

View and Edit EXIF Data from Images on Linux Command Line

What is EXIF data?

All modern digital cameras (including the one on your phone) record EXIF data when capturing an image. The information recorded in EXIF is shutter speed, date and time, aperture, ISO, and even GPS coordinates. This information can be used to organize photographs, search for specific photos, create a map of where a photo was taken, and much more. The acronym EXIF stands for Exchangeable Image File Format. In this tutorial we are going to discuss using exiftool to view and edit EXIF data on the Linux command line.st command line tool I have found.

Installing ExifTool on Linux

Let's go over how to install the exiftool on your system. If you already have it installed, you can skip to "Viewing EXIF Data" or "Editing EXIF Data".

Installing Exiftool with Your Package Manager

Most Linux distros have the Perl ExifTool package available in the repositories. This is by far the easiest (and safest) way to install exiftool. Below you will find how to install it on your favorite flavor of Linux.

# CentOS / Red Hat
sudo yum install perl-Image-ExifTool 

# Fedora
sudo dnf install perl-Image-ExifTool

# Ubuntu/Debian
sudo apt install libimage-exiftool-perl

NOTE: For CentOs/Red Hat you will have to install and enable the epel repository.

Install ExifTool with CPAN for Perl

Thanks to CPAN installation is simple. Perl comes installed by default and all you have to do is install a small Perl program via CPAN.

Refer to "How to Install PERL Modules with CPAN" for more information about installing and using CPAN for Perl Modules.

After you installed CPAN (2 minutes) you should be at a CPAN prompt (if not just type cpan at the shell prompt to start):

cpan[1]>

Type the following command:

install Image::ExifTool

This will install exiftool perl program.

Viewing EXIF Data on Linux Command Line

Now all you need to do to view the EXIF data is call the exiftool program followed by the image name like so.

Here we are viewing the EXIF data from a file named girls.jpg.

[savona@bighat]$ exiftool girls.jpg
ExifTool Version Number : 9.01
File Name : girls.jpg
Directory : .
File Size : 3.6 MB
File Modification Date/Time : 2012:09:01 23:03:01-04:00
File Permissions : rw-rw-r--
File Type : JPEG
MIME Type : image/jpeg
JFIF Version : 1.01
Exif Byte Order : Little-endian (Intel, II)
Image Description :
Make : Canon
Camera Model Name : Canon PowerShot G10
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Modify Date : 2012:09:01 23:02:57
Y Cb Cr Positioning : Co-sited
Exposure Time : 1/60
F Number : 2.8
ISO : 250
Exif Version : 0221
Date/Time Original : 2012:08:17 21:11:32
Create Date : 2012:08:17 21:11:32
...OUTPUT TRUNCATED...

Extracting Specific Information from EXIF

You can also use the program to get ONLY certain information. For example, let’s say you have multiple jpegs and you want to know which aperture you used for each image. You can use switches to pull only the information you need like so:

[savona@bighat]$ exiftool -T -Filename -Aperture *.jpg
girls.jpg 2.8
helenfu.jpg 2.2
melivairplane.jpg 2.6
schill.jpg 2.6
thehouse.jpg 5.0

NOTE: using the -T option hides the name of the tag.

Extracting Common EXIF Information

You can easily list the common EXIF information using -common like so:

[savona@bighat]$ exiftool -common Thanksgiving_2018.jpg 
File Name : Thanksgiving_2018.jpg
File Size : 4.4 MB
Camera Model Name : Canon EOS 60D
Date/Time Original : 2018:11:22 17:26:44
Image Size : 3000x2400
Focal Length : 14.0 mm
Shutter Speed : 1/60
Aperture : 4.0
ISO : 400
White Balance : Auto
Flash : On, Fired

List All Available Tags from EXIF

To get a list of all available tags for an image use the -s option:

[savona@bighat Pictures]$ exiftool -s Thanksgiving_2018.jpg 
ExifToolVersion : 11.11
FileName : Thanksgiving_2018.jpg
Directory : .
FileSize : 4.4 MB
FileModifyDate : 2018:11:23 01:02:36-05:00
FileAccessDate : 2019:02:17 14:38:06-05:00
FileInodeChangeDate : 2018:11:23 01:02:36-05:00
...OUTPUT TRUNCATED...

For this image, there are 285 available tags.

Once you know the tag you want to extract, simply call it:

[savona@bighat Pictures]$ exiftool -Megapixels Thanksgiving_2018.jpg
Megapixels : 7.2

Now that we know how to view the data, let's discuss how to edit EXIF data.

Editing EXIF Data

You can easily edit the EXIF information for photos as well.

By reading the tag -DateTimeOriginal we can see the time that was originally recorded into EXIF:

[savona@bighat Pictures]$ exiftool -DateTimeOriginal Thanksgiving_2018.jpg 
Date/Time Original : 2018:11:22 17:26:44

Let's change the date to show it was taken on January 1st 2019 at 2PM:

[savona@bighat Pictures]$ exiftool "-DateTimeOriginal=2019:01:01 14:00:00" Thanksgiving_2018.jpg 
1 image files updated

We can now confirm that the date was changed.

[savona@bighat Pictures]$ exiftool -DateTimeOriginal Thanksgiving_2018.jpg 
Date/Time Original : 2019:01:01 14:00:00

More Examples of Editing EXIF Data

I share some of my cameras with my daughter who also loves photography. Because of this I do not want to set the copyright in camera, I do it after I load the images on my computer.

[savona@bighat Pictures]$ exiftool -copyright="Steven Vona" Thanksgiving_2018.jpg
1 image files updated
[savona@bighat Pictures]$ exiftool -copyright Thanksgiving_2018.jpg
Copyright : Steven Vona

Conclusion

The exiftool is a very powerful program. It comes in handy, especially for folks who perfer the command line. We barely scratched the surface of what is capable of.

There are a lot of neat things you can do like conditionally process files (if aperture = 2.8 move it to the bokeh folder), change dates, add copyright info and more.

To find out more you can read the help file:

[savona@bighat jpg]$ exiftool --help

If anyone has any cool uses for the program I would love to hear them in the comments!

Resources

ExifTool By Phil Harvey Homepage

Exit mobile version