The tool that IPTC recommends the most for command-line use is Phil Harvey’s exiftool ExifTool (exiftool.org).
How you install the exiftool ExifTool software depends on your operating system and environment. Here are some installation instructions.
It has extensive documentation online. You can also run exiftool
with no arguments for a complete list of available options with examples.
...
Table of Contents | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Examples of reading IPTC metadata from the command line using exiftool
To get you started quickly, here are some examples of things that can be done with it exiftool
regarding IPTC metadata (we cover writing these fields below)
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:
...
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 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 -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:
And to ensure that the returned field names match those given in the input (e.g. “XMP-dc:creator” rather than just “Creator”), use the -G1 flag:
Code Block |
---|
% exiftool -G1 -structjson -XMP-plusdc:Licensorcreator test-image.jpg Licensor[{ : [{LicensorCity=Licensor City 1 (ref2021.1),LicensorCountry=Licensor Country 1 (ref2021.1),LicensorEmail="SourceFile": "test-image.jpg", "XMP-dc: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 -G1 -json -struct -XMP-plus:Licensor test-image.jpg [{ "SourceFile": "test-image.jpg", "XMP-plus:Licensor": [{ "LicensorCity": "Licensor City 1 (ref2021.1)", "LicensorCountry": "Licensor Country 1 (ref2021.1)", "LicensorEmail": "Licensor Email 1 (ref2021.1)",LicensorExtendedAddress= "LicensorExtendedAddress": "Licensor Ext Addr 1 (ref2021.1)",LicensorID= "LicensorID": "Licensor ID 1 (ref2021.1)",LicensorName= "LicensorName": "Licensor Name 1 (ref2021.1)",LicensorPostalCode= "LicensorPostalCode": "Licensor Postcode 1 (ref2021.1),LicensorRegion=", "LicensorRegion": "Licensor Region 1 (ref2021.1)",LicensorStreetAddress= "LicensorStreetAddress": "Licensor Street Addr 1 (ref2021.1)",LicensorTelephone1= "LicensorTelephone1": "Licensor Phone1 1 (ref2021.1)",LicensorTelephone2= "LicensorTelephone2": "Licensor Phone2 1 (ref2021.1)",LicensorTelephoneType1=Work,LicensorTelephoneType2=Cell,LicensorURL=Licensor URL 1 (ref2021.1)},{LicensorCity= "LicensorTelephoneType1": "Work", "LicensorTelephoneType2": "Cell", "LicensorURL": "http://www.newlicensorurl.com/" },{ "LicensorCity": "Licensor City 2 (ref2021.1)",LicensorCountry= "LicensorCountry": "Licensor Country 2 (ref2021.1),LicensorEmail=", "LicensorEmail": "Licensor Email 2 (ref2021.1)",LicensorExtendedAddress= "LicensorExtendedAddress": "Licensor Ext Addr 2 (ref2021.1)",LicensorID= "LicensorID": "Licensor ID 2 (ref2021.1)",LicensorName= "LicensorName": "Licensor Name 2 (ref2021.1)",LicensorPostalCode= "LicensorPostalCode": "Licensor Postcode 2 (ref2021.1),LicensorRegion=1)", "LicensorRegion": "Licensor Region 2 (ref2021.1)",LicensorStreetAddress= "LicensorStreetAddress": "Licensor Street Addr 2 (ref2021.1)",LicensorTelephone1= "LicensorTelephone1": "Licensor Phone1 2 (ref2021.1),LicensorTelephone2=Licensor Phone2 2 (ref2021.1),LicensorTelephoneType1=Work,LicensorTelephoneType2=Cell,LicensorURL=Licensor URL", "LicensorTelephone2": "Licensor Phone2 2 (ref2021.1)", "LicensorTelephoneType1": "Work", "LicensorTelephoneType2": "Cell" }] }] |
View all properties read by Google Image Search for the Licensable badge feature
To read more than one property from a file, simply specify multiple Exiftool ExifTool tags, each prefixed with a dash/hyphen character.
Code Block |
---|
% exiftool -G1 -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL:LicensorURL IPTC-GoogleImgSrcPmd_testimg01.jpg [XMP-dc] IPTC-GoogleImgSrcPmd_testimg01.jpg Creator : Jane Photosty [XMP-photoshop] Credit : IPTC/Jane Photosty [XMP-dc] Rights : © Copyright 2020 IPTC (Test Images) - www.iptc.org [XMP-xmpRights] Web Statement : https://iptc.org/tests/copyright-and-licenses-of-images-test-page/ [XMP-plus] 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 -G1 -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL -XMP-iptcExt:DigitalSourceType test-image.jpg [XMP-dc] Creator : New Creator, Additional 1Creator, Additional Creator 2[XMP-photoshop] Credit : New Credit Line (ref2021.1) Rights [XMP-dc] Rights : Copyright (Notice) 2021.1 IPTC: - www.iptc.org (ref2021.1)New Rights line [XMP-xmpRights] Web Statement : http://www.WebStatementOfRights.org/2021.1 Licensor URL New Web Statement of Rights [XMP-plus] Licensor URL : Licensor URL 1 (ref2021.1), Licensor URL 2 (ref2021.1): http://www.newlicensorurl.com/ [XMP-iptcExt] 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 that is stored within an image file. This is usually only used needed for debugging purposes or if you are curious about how this XMP 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> |
Anchor | ||||
---|---|---|---|---|
|
...
ExifTool
The same exiftool ExifTool XMP tags can be used to write metadata to image files on the command line.
Info |
---|
Note that by default when writing to an image file using |
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:
...
(Note that Google’s documentation on Digital Source Type for synthetic media specifies using only the ID, not the full URI. So if you are writing software to read these values, we recommend that you support both the fully-expanded URI and the short ID.)
Writing Creator and Credit Line metadata
The contents of these fields will be displayed in the Google Images search results details panel.
Code Block |
---|
% exiftool -XMP-dc:creator="Jane Smith" -XMP-photoshop:Credit="Jane Smith, Smith Photography Ltd" -XMP-dc:rights="Copyright Smith Photography Ltd 2023" -XMP-xmpRights:WebStatement="http://smithphotography.com/licensing/" -XMP-plus:LicensorURL="http://www.mypictureagency.com/obtain-licence/" -XMP-iptcExt:DigitalSourceType="https://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture" test-image.jpg 1 image files updated brendan@Brendans-M1-MacBook-Pro pmd-sample-images % exiftool -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL -XMP-iptcExt:DigitalSourceType test-image.jpg Creator : Jane Smith Credit : Jane Smith, Smith Photography Ltd Rights : Jane Smith Credit : Copyright Smith Photography Ltd 2023 Web Statement : Jane Smith, Smith Photography Ltd Rights : http://smithphotography.com/licensing/ Licensor URL : Copyright Smith Photography Ltd 2023 Web Statement : http://www.mypictureagency.com/obtain-licence/ Digital Source Type : httphttps://smithphotography.com/licensing/ Licensor URL : cv.iptc.org/newscodes/digitalsourcetype/digitalCapture |
Writing Licensor URL metadata
This triggers the “Get this image on…” text in Google Images search results.
Code Block |
---|
% exiftool -XMP-plus:LicensorURL=http://www.mypictureagency.com/obtain-licence/ Digital Source Typetest-image.jpg 1 image : https://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture |
Writing Licensor URL metadata
This triggers the “Get this image on…” text in Google Images search results.
Code Block |
---|
% exiftool files updated |
Note that this approach will not work if there are already two or more Licensor records in the image metadata. This is because the exiftool argument -XMP-plus:
...
LicensorURL
is a shortcut for “the LicensorURL sub-property in the first Licensor structure in the image.” But for most images, there will be only one licensor record or more likely no records at all, so this shortcut will work.
If you need to edit the LicensorURL of an image with two or more Licensor records, you should use the
Writing Web Statement of Rights metadata
This triggers the “Licensable” badge in Google image search results.
Code Block |
---|
% exiftool -XMP-xmpRights:WebStatement="http://smithphotography.com/licensing/" test-image.jpg 1 image files updated brendan@Brendans-M1-MacBook-Pro pmd-sample-images % exiftool -XMP-xmpRights:WebStatement test-image.jpg Web Statement : http://smithphotography.com/licensing/ |
Writing all metadata that can be read by Google Search
Code Block |
---|
% exiftool -XMP-dc:creator="Jane Smith" -XMP-photoshop:Credit="Jane Smith, Smith Photography Ltd" -XMP-dc:rights="Copyright Smith Photography Ltd 2023" -XMP-xmpRights:WebStatement="http://smithphotography.com/licensing/" -XMP-plus:LicensorURL="http://www.mypictureagency.com/obtain-licence/" -XMP-iptcExt:DigitalSourceType="https://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture" test-image.jpg
1 image files updated
brendan@Brendans-M1-MacBook-Pro pmd-sample-images % exiftool -XMP-dc:creator -XMP-photoshop:Credit -XMP-dc:rights -XMP-xmpRights:WebStatement -XMP-plus:LicensorURL -XMP-iptcExt:DigitalSourceType test-image.jpg
Creator : Jane Smith
Credit : Jane Smith, Smith Photography Ltd
Rights : Copyright Smith Photography Ltd 2023
Web Statement : http://smithphotography.com/licensing/
Licensor URL : http://www.mypictureagency.com/obtain-licence/
Digital Source Type : https://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture |
Appending to an existing set of repeatable tags
exiftool allows appending to a repeatable list of tags, for example Image Creator (dc:creator):
Code Block |
---|
% exiftool '-XMP-dc:creator+=New Creator' test-image.jpg 1 image files updated % exiftool -XMP-dc:creator test-image.jpg Creator : Creator 1, Creator 2, New Creator |
Do you have other questions? Would you like more examples? Have you spotted a problem? Just ask!
If you would like to see other exiftool examples, or if you have suggestions of exiftool incantations that you find useful and you would like to share them with others, please let us know!