How to View or Edit PDF/Image Metadata from Command Line

Home / How to View or Edit PDF/Image Metadata from Command Line

Typical digital images or photos have a rich set of metadata embedded in them. Metadata is automatically written by capture device such as digital cameras, or it can be manually added by photographers or photo editing software to show various properties. Similarly, a pdf document also have its own set of metadata associated with them to identify author, title, date, etc.

There are various tools that allow us to edit metadata in digital photos or pdf documents and ExifTool is one of it. ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files. ExifTool supports many different metadata formats including EXIF, GPS, IPTC, XMP, JFIF, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP and ID3, as well as the maker notes of many digital cameras by Canon, Casio, FLIR, FujiFilm, GE, HP, JVC/Victor, Kodak, Leaf, Minolta/Konica-Minolta, Nikon, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Phase One, Reconyx, Ricoh, Samsung, Sanyo, Sigma/Foveon and Sony.

In this article, we will discuss about how to view or edit metadata in pdf documents or digital pictures from command line using ExifTool. All of experiments have been done on Slackware64 14.0.

Supported Metadata

Below is the 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)

Installation

As stated before, ExifTool is using Perl. ExifTool requires Perl 5.004 or later. No other library or software is required.

Package Manager Way

To install ExifTool on Ubuntu, Debian or Linux Mint you can use following command:

sudo apt-get install libimage-exiftool-perl

To install ExifTool on CentOS or RHEL, first you need to set up EPEL repository, and then run the following:

sudo yum install perl-Image-ExifTool

Generic Way

Installing ExifTool from source is really simple.

Download the source code, the latest version is 9.37

wget http://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-9.37.tar.gz

Extract and go to the source code’s root directory:

tar -xzvf Image-ExifTool-9.37.tar.gz
cd Image-ExifTool-9.37

next, invoke following commands to test and install:

perl Makefile.PL
make test
sudo make install

Windows Way

In Windows, there is a choice of two different versions of ExifTool to install. If you don’t already have Perl, it is easier to install the stand-alone ExifTool executable, but note that the stand-alone version doesn’t include the HTML documentation or some other files of the full distribution.

The stand-alone executable can be downloaded from ExifTool home page: exiftool-9.37.zip. After download it, extract “exiftool(-k).exe”. Rename and move it as to C:\Windows\exiftool.exe.

You can now run exiftool by typing “exiftool” at the command prompt.

Usage Example

View all metadata in a picture

exiftool input.jpg

Change title and author information of a pdf document

exiftool -Title=”A title by Satria” -Author=”Satria Ady Pradana” input.pdf

Modify tags of multiple image in a batch

exiftool -artist=”Satria Ady Pradana” -copyright=”2013 Satria Ady Pradana” a.jpg b.jpg c.jpg

Modify artist name for all media files located in a target directory

exiftool -artist=”Satria Ady Pradana” ./folder

Show all Metadata information in an Image

This will include duplicate and unknown tags, sorted by group.

exiftool -a -u -g2 input.jpg

Show all metadata fields which contains the word “Date”

exiftool -”*Date*” input.png

Extract GPS coordinate information from a photo

exiftool -gpslatitude -gpslongitude input.jpg

Show GPS coordinate information contained in a picture in tabular format

exiftool -filename -gpslatitude -gpslongitude -T input.jpg

 

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial