How to add IPTC metadata in photographs using exiv2 in Linux

  • Post author:
  • Post last modified:August 13, 2024
  • Reading time:4 mins read

1.0 Adding the IPTC metadata

After a photograph has been taken and processed, it might be necessary to add the International Press Telecommunications Council (IPTC) metadata before it can be published. If your image editing software does not support adding of IPTC metadata to the image, you can accomplish this is by using the exiv2 command in Linux.

2.0 An example

Suppose we have an image file, example.jpg and we wish to add the metadata for the headline and caption fields. We can do that using the exiv2 command.

$ exiv2 -M "add Iptc.Application2.Headline An example headline" example.jpg
$ exiv2 -M "add Iptc.Application2.Caption An example caption." example.jpg

3.0 Image metadata

Image metadata gives information about the image. Exif (Exchangeable image file format) metadata is the most common as it is created by the camera when the image is captured. Exif data comprises of the time stamp of the image capture, camera settings like the shutter speed, aperture value, ISO sensitivity, white balance, etc. IPTC (International Press Telecommunications Council) metadata standard aims at embedding captions, tags, time stamps, rights and licensing information in the image file. Similarly, XMP (Extensible Metadata Platform) is a standard for serialization and exchange of standard and custom image metadata. In the rest of this tutorial we will focus on the IPTC metadata.

4.0 exiv2 command

exiv2 is a command for read and write of Exif, IPTC and XMP metadata fields in image files. exiv2 supports jpeg, png, gif, bmp, tiff and more image files. It also supports raw camera files like CR2, NEF, etc.

The exiv2 command syntax is,

exiv2 [options] [action] file ...

Both options and action are optional. The command exiv2 file prints the Exif data for the file. For example,

$ exiv2 example.jpg
File name       : example.jpg
File size       : 30735668 Bytes
MIME type       : image/jpeg
Image size      : 6024 x 4024
Camera make     : XXXXX CORPORATION
Camera model    : XXXXX XXXX
Image timestamp : 2017:10:03 11:56:03
Image number    : 
Exposure time   : 1/800 s
Aperture        : F18
Exposure bias   : 0 EV
Flash           : 
Flash bias      : 
Focal length    : 24.0 mm (35 mm equivalent: 24.0 mm)
Subject distance: 
ISO speed       : 900
Exposure mode   : Manual
Metering mode   : Multi-segment
Macro mode      : 
Image quality   : RAW    
Exif Resolution : 
White balance   : AUTO1       
Thumbnail       : None
Copyright       : John Doe 
Exif comment    : 

We can print the IPTC metadata using the exiv2 -pi filename command.

$ exiv2 -pi example.jpg
Iptc.Application2.Headline                   String     19  An example headline
Iptc.Application2.ObjectAttribute            String     24  Object attribute - Genre
Iptc.Application2.ObjectName                 String      9  The title
Iptc.Application2.Subject                    String      9  Subject-1
Iptc.Application2.Subject                    String      9  Subject-2
Iptc.Application2.Subject                    String      9  Subject-3
Iptc.Application2.Keywords                   String     10  Keywords-1
Iptc.Application2.Keywords                   String     10  Keywords-2
Iptc.Application2.Keywords                   String     10  Keywords-3
Iptc.Application2.SpecialInstructions        String     20  Special Instructions
Iptc.Application2.DateCreated                Date        8  2017-10-03
Iptc.Application2.TimeCreated                Time       11  11:56:03+05:30
Iptc.Application2.Byline                     String      9  Creator-1
Iptc.Application2.BylineTitle                String     19  Creator's Job Title
Iptc.Application2.City                       String      4  City
Iptc.Application2.SubLocation                String     11  Sublocation
Iptc.Application2.ProvinceState              String     17  Province or State
Iptc.Application2.CountryCode                String      3  AAA
Iptc.Application2.CountryName                String     12  Country Name
Iptc.Application2.TransmissionReference      String      6  Job Id
Iptc.Application2.Credit                     String     11  Credit Line
Iptc.Application2.Source                     String      6  Source
Iptc.Application2.Copyright                  String     16  Copyright notice
Iptc.Application2.Caption                    String     25  The description (caption)
Iptc.Application2.Writer                     String     18  Description writer
Iptc.Application2.RecordVersion              Short       1  5

5.0 Reference

Karunesh Johri

Software developer, working with C and Linux.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments