How to view or edit PDF/image metadata from command line on Linux

Last updated on December 1, 2020 by Dan Nanni

Typical digital images or photos have a rich set of metadata embedded in them. The metadata is automatically written by digital cameras, or manually added by photographers or photo editing software, to show various properties (e.g., creator, camera info, location) of a particular picture. PDF documents also have its own set of metadata associated with them to identify author, title, date, etc.

Unless you want to strip off the metadata from images or documents for your privacy, there are various tools that allow you to selectively edit the metadata in digital photos or PDF documents. ExifTool is a powerful command-line utility that can read or write meta information in a file. It is available on Linux, Windows or MacOS X.

In this tutorial, I will describe how to view or edit metadata in PDF documents or digital pictures from the command line on Linux with ExifTool.

Install ExifTool on Linux

ExifTool requires Perl 5.004 or later. No other library or software is required.

To install ExifTool on Ubuntu, Debian or Linux Mint:

$ sudo apt-get install libimage-exiftool-perl

To install ExifTool on Fedora:

$ sudo yum install perl-Image-ExifTool

To install ExifTool on CentOS or RHEL, first enable EPEL repository, and then run:

$ sudo yum install perl-Image-ExifTool

Metadata Supported by ExifTool

Below is a list of file types and metadata currently supported by ExifTool (r = read, w = write, c = create).

Supported file types:

------------+-------------+-------------+-------------+------------
3FR   r     | DVB   r     | M4A/V r     | PBM   r/w   | RWL   r/w
3G2   r     | DYLIB r     | MEF   r/w   | PDF   r/w   | RWZ   r
3GP   r     | EIP   r     | MIE   r/w/c | PEF   r/w   | RM    r
ACR   r     | EPS   r/w   | MIFF  r     | PFA   r     | SO    r
AFM   r     | ERF   r/w   | MKA   r     | PFB   r     | SR2   r/w
AI    r/w   | EXE   r     | MKS   r     | PFM   r     | SRF   r
AIFF  r     | EXIF  r/w/c | MKV   r     | PGF   r     | SRW   r/w
APE   r     | F4A/V r     | MNG   r/w   | PGM   r/w   | SVG   r
ARW   r/w   | FLA   r     | MOS   r/w   | PICT  r     | SWF   r
ASF   r     | FLAC  r     | MOV   r     | PMP   r     | THM   r/w
AVI   r     | FLV   r     | MP3   r     | PNG   r/w   | TIFF  r/w
BMP   r     | FPX   r     | MP4   r     | PPM   r/w   | TTC   r
BTF   r     | GIF   r/w   | MPC   r     | PPT   r     | TTF   r
COS   r     | GZ    r     | MPG   r     | PPTX  r     | VRD   r/w/c
CR2   r/w   | HDP   r/w   | MPO   r/w   | PS    r/w   | VSD   r
CRW   r/w   | HTML  r     | MQV   r     | PSB   r/w   | WAV   r
CS1   r/w   | ICC   r/w/c | MRW   r/w   | PSD   r/w   | WDP   r/w
DCM   r     | IIQ   r/w   | MXF   r     | PSP   r     | WEBP  r
DCP   r/w   | IND   r/w   | NEF   r/w   | QTIF  r     | WEBM  r
DCR   r     | ITC   r     | NRW   r/w   | RA    r     | WMA   r
DFONT r     | JNG   r/w   | NUMBERS r   | RAF   r/w   | WMV   r
DIVX  r     | JP2   r/w   | ODP   r     | RAM   r     | X3F   r/w
DJVU  r     | JPEG  r/w   | ODS   r     | RAR   r     | XCF   r
DLL   r     | K25   r     | ODT   r     | RAW   r/w   | XLS   r
DNG   r/w   | KDC   r     | OGG   r     | RIFF  r     | XLSX  r
DOC   r     | KEY   r     | ORF   r/w   | RSRC  r     | XMP   r/w/c
DOCX  r     | LNK   r     | OTF   r     | RTF   r     | ZIP   r
DV    r     | M2TS  r     | PAGES r     | RW2   r/w   |

Supported metadata standards and types:

----------------------+----------------------+---------------------
EXIF           r/w/c  |  CIFF           r/w  |  Ricoh RMETA    r
GPS            r/w/c  |  AFCP           r/w  |  Picture Info   r
IPTC           r/w/c  |  Kodak Meta     r/w  |  Adobe APP14    r
XMP            r/w/c  |  FotoStation    r/w  |  MPF            r
MakerNotes     r/w/c  |  PhotoMechanic  r/w  |  Stim           r
Photoshop IRB  r/w/c  |  JPEG 2000      r    |  APE            r
ICC Profile    r/w/c  |  DICOM          r    |  Vorbis         r
MIE            r/w/c  |  Flash          r    |  SPIFF          r
JFIF           r/w/c  |  FlashPix       r    |  DjVu           r
Ducky APP12    r/w/c  |  QuickTime      r    |  M2TS           r
PDF            r/w/c  |  Matroska       r    |  PE/COFF        r
PNG            r/w/c  |  GeoTIFF        r    |  AVCHD          r
Canon VRD      r/w/c  |  PrintIM        r    |  ZIP            r
Nikon Capture  r/w/c  |  ID3            r    |  (and more)

Exiftool Examples

To view all metadata in a picture:

$ exiftool input.jpg
ExifTool Version Number         : 8.60
File Name                       : 1.jpg
Directory                       : .
File Size                       : 3.2 MB
File Modification Date/Time     : 2013:08:27 17:00:28-04:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : SONY
Camera Model Name               : DSLR-A900
Orientation                     : Horizontal (normal)
X Resolution                    : 240
Y Resolution                    : 240
Resolution Unit                 : inches
Software                        : Adobe Photoshop CS5 Windows
Modify Date                     : 2013-08-26T19:50:43+01:00
Artist                          : Dan N
Copyright                       : Sean Barden
Exposure Time                   : 1/200
F Number                        : 7.1
Exposure Program                : Manual
ISO                             : 100
. . .

To change the title and author information of a PDF document:

$ exiftool -Title="This is the title" -Author="Dan Nanni" input.pdf

To modify tags of multiple images in a batch:

$ exiftool -artist="Dan Nanni" -copyright="2013 Dan Nanni" a.jpg b.jpg c.jpg

To modify artist name for all media files located in a target directory:

$ exiftool -artist="Dan Nanni" ./folder

To show all metadata information in an image, including duplicate and unknown tags, sorted by group (for family 1):

$ exiftool -a -u -g2 input.jpg

To show all metadata fields which contain the word Date:

$ exiftool -"*Date*" input.png
File Modification Date/Time     : 2013:08:24 00:54:58-04:00
Modify Date                     : 2013:08:24 04:54:58

To extract GPS coordinate information from a photo:

$ exiftool -gpslatitude -gpslongitude  input.jpg
GPS Latitude                    : 54 deg 9' 42.68" N
GPS Longitude                   : 5 deg 58' 35.93" W

To show GPS coordinate information contained in a picture in a tabular format (e.g., <filename> <latitude> <longitude>):

$ exiftool -filename -gpslatitude -gpslongitude -T input.jpg
input.jpg    54 deg 9' 42.68" N    5 deg 58' 35.93" W

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (BTC Wallet: 1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g).

Xmodulo © 2020 ‒ About ‒ Powered by DigitalOcean