JMM’s notes on

ExifTool

Command Line

Get EXIF data

Running exiftool $YOURFILE will output something like:

ExifTool Version Number         : 12.50
File Name                       : test.png
Directory                       : .
File Size                       : 5.0 kB
File Modification Date/Time     : 2023:12:05 15:03:53-08:00
File Access Date/Time           : 2023:12:05 15:03:53-08:00
File Inode Change Date/Time     : 2023:12:05 15:38:48-08:00
File Permissions                : -rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 298
Image Height                    : 92
Bit Depth                       : 8
Color Type                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Significant Bits                : 8 8 8 8
Software                        : gnome-screenshot
Creation Time                   : Tue 05 Dec 2023 03:03:41 PM PST
Image Size                      : 298x92
Megapixels                      : 0.027

Remove EXIF data

exiftool -all= -tagsfromfile src.jpg -exif:all dst.jpg

(TODO: Haven’t yet checked if this correctly handles orientation. Normally I use “mogrify -auto-orient -strip $FILE”. )

Also, you shouldn’t do this if the metadata contains licensing info.

Add metadata

Here’s how you might add some info to a screenshot:

exiftool -artist="Josh Mōller-Mara" $FILE

If you want it in XMP:

exiftool -XMP-dc:Creator="Josh Mōller-Mara" $FILE

XMP

Also see XMP Tags.

Here’s how you’d output XMP to standard output:

exiftool $FILE -o -.xmp

or exiftool -tagsfromfile a.jpg out.xmp if you want to output to a file.

That’ll give you something like:

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.50'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

 <rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:creator>
   <rdf:Seq>
    <rdf:li>Josh Mōller-Mara</rdf:li>
   </rdf:Seq>
  </dc:creator>
 </rdf:Description>

 <rdf:Description rdf:about=''
  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
  <tiff:Artist>Josh Mōller-Mara</tiff:Artist>
  <tiff:ImageLength>92</tiff:ImageLength>
  <tiff:ImageWidth>298</tiff:ImageWidth>
  <tiff:Software>gnome-screenshot</tiff:Software>
 </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

To copy XMP to another file:

exiftool -all= -tagsfromfile out.xmp -xmptoolkit= a.png

This also prevents the XMP toolkit tag from being created.

XMP for a screenshot

Mark with a title, description, and license under Creative Commons.

exiftool -XMP-dc:Creator="Josh Mōller-Mara" \
	 -XMP-dc:Date="$(date +%Y-%m-%d)" \
	 -XMP-dc:Title='Some title' \
	 -XMP-dc:Description='Some description' \
	 -XMP-dc:Rights="© Copyright $(date +%Y) Josh Moller-Mara" \
	 -XMP-cc:AttributionName="Josh Mōller-Mara" \
	 -XMP-cc:AttributionURL="https://jmm.io/" \
	 -XMP-cc:License="https://creativecommons.org/licenses/by-sa/4.0/" \
	 -XMP-xmpRights:Marked=true \
	 -XMP-xmpRights:UsageTerms="This image is licensed under Creative Commons Attribution-ShareAlike 4.0 International" \
	 -xmptoolkit= \
	 $FILE

If you set the file to something like “out.xmp”, it’ll just create an XMP file from these tags. This can be handy if you’re writing XMP metadata with another program, for example with WebP metadata (since ExifTool can’t write WebP files).