Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The tool that we recommend the most for command-line use is Phil Harvey’s exiftool (exiftool.org).

...

It has extensive documentation and you can also run exiftool with no arguments for a complete list of available options with examples.

Simple exiftool command-line examples

To get you started quickly, here are some examples of things that can be done with it regarding IPTC metadata:

View all embedded metadata for an image file

Simply run exiftool with the file name / path to the image file that you wish to investigate:

Code Block
exiftool <image file name>

This will simply display all metadata (IPTC, Exif and other formats) that can be extracted from the file.

View a single-valued metadata property

...

in an image file

Exiftool can extract any single property from a media file. To find out which tag to use, first consult the IPTC Photo Metadata Standard Specification to get the XMP tag used, then consult the exiftool XMP tags page to determine how to specify that tag for exiftool.

Show only the Digital Source Type value

Code Block
$% exiftool -XMP-iptcExt:digitalsourcetype IPTC-PhotometadataRef-Std2021.1.jpg
Digital Source Type             : http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage 

...

Show only the Credit Line value

Code Block
$% exiftool -struct -XMP-photoshop:Credit IPTC-PhotometadataRef-Std2021.1.jpg
Credit                          : Credit Line (ref2021.1)

...

View multi-valued properties in image files

Here’s an example of viewing a non-structured but multi-valued property:

Show the creator value(s)

By default, exiftool shows multi-valued properties as comma-separated values on the same line:

Code Block
% exiftool -XMP-dc:creator test-image.jpg
Creator                         : Creator 1, Creator 2

Using the -struct option shows more clearly that it is in fact a list of values:

Code Block
% exiftool -struct -XMP-dc:creator test-image.jpg
Creator                         : [Creator 1,Creator 2]

To make it totally clear that it is in fact a repeatable value, you can ask for JSON-encoded output:

Code Block
% exiftool -json -XMP-dc:creator test-image.jpg
[{
  "SourceFile": "test-image.jpg",
  "Creator": ["Creator 1","Creator 2"]
}]

View a structured property for an image file

Some properties (such as Licensor which is used for Google’s Licensable feature) are structured, which means they contain sub-properties. In this case, running the simple exiftool -XMP-plus:Licensor test-image.jpg returns no results.

The secret is to use the -struct option:

Code Block
% exiftool -struct -XMP-plus:Licensor test-image.jpg
Licensor                        : [{LicensorCity=Licensor City 1 (ref2021.1),LicensorCountry=Licensor Country 1 (ref2021.1),LicensorEmail=Licensor Email 1 (ref2021.1),LicensorExtendedAddress=Licensor Ext Addr 1 (ref2021.1),LicensorID=Licensor ID 1 (ref2021.1),LicensorName=Licensor Name 1 (ref2021.1),LicensorPostalCode=Licensor Postcode 1 (ref2021.1),LicensorRegion=Licensor Region 1 (ref2021.1),LicensorStreetAddress=Licensor Street Addr 1 (ref2021.1),LicensorTelephone1=Licensor Phone1 1 (ref2021.1),LicensorTelephone2=Licensor Phone2 1 (ref2021.1),LicensorTelephoneType1=Work,LicensorTelephoneType2=Cell,LicensorURL=Licensor URL 1 (ref2021.1)},{LicensorCity=Licensor City 2 (ref2021.1),LicensorCountry=Licensor Country 2 (ref2021.1),LicensorEmail=Licensor Email 2 (ref2021.1),LicensorExtendedAddress=Licensor Ext Addr 2 (ref2021.1),LicensorID=Licensor ID 2 (ref2021.1),LicensorName=Licensor Name 2 (ref2021.1),LicensorPostalCode=Licensor Postcode 2 (ref2021.1),LicensorRegion=Licensor Region 2 (ref2021.1),LicensorStreetAddress=Licensor Street Addr 2 (ref2021.1),LicensorTelephone1=Licensor Phone1 2 (ref2021.1),LicensorTelephone2=Licensor Phone2 2 (ref2021.1),LicensorTelephoneType1=Work,LicensorTelephoneType2=Cell,LicensorURL=Licensor URL 2 (ref2021.1)}]

View all properties read by Google Image Search for the Licensable badge feature

Code Block
% exiftool -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL   IPTC-GoogleImgSrcPmd_testimg01.jpg
Creator                         : Jane Photosty
Credit                          : IPTC/Jane Photosty
Rights                          : © Copyright 2020 IPTC (Test Images) - www.iptc.org
Web Statement                   : https://iptc.org/tests/copyright-and-licenses-of-images-test-page/
Licensor URL                    : https://iptc.org/tests/licensing-of-images-test-page/

View all properties read by Google Image Search for Licensable badge and Synthetic Media features

Code Block
% exiftool -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL -XMP-iptcExt:DigitalSourceType  test-image.jpg                   
Creator                         : Creator 1, Creator 2
Credit                          : Credit Line (ref2021.1)
Rights                          : Copyright (Notice) 2021.1 IPTC - www.iptc.org  (ref2021.1)
Web Statement                   : http://www.WebStatementOfRights.org/2021.1
Licensor URL                    : Licensor URL 1 (ref2021.1), Licensor URL 2 (ref2021.1)
Digital Source Type             : https://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia

View the full XMP data for an image file

This displays the native internal structure of the XMP packet within an image file. This is usually only used for debugging purposes or if you are curious about how this metadata is actually stored inside the file.

Code Block
$ exiftool -b -xmp IPTC-PhotometadataRef-Std2021.1.jpg
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.34'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
  Iptc4xmpCore:AltTextAccessibility
   rdf:Alt
    <rdf:li xml:lang='x-default'>This is the Alt Text description to support accessibility in 2021.1</rdf:li>
   </rdf:Alt>
  </Iptc4xmpCore:AltTextAccessibility>
  <Iptc4xmpCore:CountryCode>R21</Iptc4xmpCore:CountryCode>

  [... much more data snipped for brevity ...]

  </xmpRights:UsageTerms>
  <xmpRights:WebStatement>http://www.WebStatementOfRights.org/2021.1</xmpRights:WebStatement>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>

Writing embedded metadata to image files using exiftool

The same exiftool versions of XMP tags can be used to write metadata to image files on the command line:

Writing Digital Source Type for synthetic media

Note that the value can be any text string, but we recommend using a full URI from the IPTC Digital Source Type vocabulary:

Code Block
% exiftool -XMP-iptcExt:digitalsourcetype=https://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia test-image.jpg
    1 image files updated

(Note that Google’s documentation on Digital Source Type for synthetic media specifies using only the value, not the full URI. So if you are writing software to read these values, we recommend that you support both formats.)

Writing Licensor