Using ExifTool

Remove All Metadata

If you don't want your photos to leak any kind of information, you might want to remove all metadata before publishing them on the web. ExifTool lets you do that with consummate ease. To remove all metadata in one fell swoop from a specific photo, use the

exiftool -all= path/to/foo.jpg

command (note the whitespace after the = character).

When you run this command (or any other exiftool command that modifies metadata), ExifTool conveniently creates a backup copy of the photo with the _original postfix before performing any actions. This way, you can always revert to the original if something goes wrong. Sometimes, for example when you need to process a large collection of photos, this feature can be more of a nuisance than help. In this case, you can use the -overwrite_original parameter, which forces ExifTool to modify metadata without creating a backup copy first; for example:

exiftool -overwrite_original -all= path/to/foo.jpg

Of course, you can process all files in a directory by specifying its path (or . to denote the current working directory):

exiftool -overwrite_original -all= .

Instead of erasing all metadata, you can use ExifTool to remove only values of specific tags. For example, when publishing photos on the web, you might want to keep key photographic metadata (aperture, shutter speed, focal length, ISO, etc.) and remove geographical coordinates that reveal where the photo was taken. The command

exiftool -ext JPG -overwrite_original -gps:all= .

lets you accomplish just that.

Write and Modify Metadata

With ExifTool, you can not only remove metadata but also modify it. This functionality can be useful in many situations. For example, if you want to add basic photographic information to digitized film negatives, ExifTool is your best friend. The following command writes the camera make and model, aperture, shutter speed, and ISO values into the specified file:

exiftool -make='Nippon Kogaku K.K.' -model='Nikomat FTn' -fnumber='8' -exposuretime='1/500' -iso='400' foo.jpg

If you plan to use this command often, you can turn it into a simple Bash script:

#!/bin/bash
exiftool -make="$1" -model="$2" -fnumber=$3 -exposuretime=$4 -iso=$5 $6

Save this script under the exifwrite.sh name and make it executable using the

chmod +x exifwrite.sh

command. The next time you need to write data into a photo, you can run the script supplying it with the required values:

./exifwrite.sh 'Nippon Kogaku K.K.' 'Nikomat FTn' 11 1/125 400 foo.jpg

Another simple command can help you geotag a set of photos quickly:

exiftool -ext JPG -GPSLongitudeRef=E -GPSLongitude=139.7513889 \
  -GPSLatitudeRef=N -GPSLatitude=35.685 .

Of course, to use this command, you need to know the exact geographical coordinates of the place the photos were taken. However, a little trick can save you time and effort. When you're done shooting a scene or a subject, take a reference photo with your Android or iOS device (make sure that the geotagging feature in the camera app is turned on). Then use the following command to copy geographical data from the reference file (foo.jpg) and write it into the photos in the current working directory:

exiftool -overwrite_original -P -tagsFromFile foo.jpg -gps:all .

The -P switch in this command preserves the date and time of files. Instead of using reference photos, you can use a GPS tracking app like Open GPS Tracker for Android [3] to create GPS logfiles, then use ExifTool to geocorrelate photos:

exiftool -geotag track.log /path/to/photos

The utility can handle logfiles in several formats, including GPX, NMEA, KML, and Garmin XML.

Other Clever Uses

Using ExifTool, you can easily add keywords (also called tags in other photo management applications like digiKam) and remove specific keywords, too:

exiftool -overwrite_original -keywords+='Berlin' .
exiftool -keywords-='Berlin' .

This functionality can be particularly useful if you happen to use digiKam. Although this application makes it supremely easy to assign tags to photos, it's not particularly good at dealing with existing tags. For example, if you assign the tokyo tag to photos and then rename it to Tokyo, the photos end up containing both tokyo and Tokyo tags. Also, deleting a tag in digiKam doesn't actually remove it from the photo. Of course, digiKam comes with a tool for editing metadata, but using it is not practical when you need to process dozens or hundreds of photos. This is where ExifTool comes into the picture. Removing a specific keyword from or adding a tag to photos in the current directory with ExifTool is a matter of running the following commands:

exiftool -overwrite_original -keywords-='tokyo' .
exiftool -overwrite_original -keywords+='Tokyo' .

Now suppose you need to find out which photos contain a specific tag. Here is the command for that:

exiftool -if '$keywords =~ /Berlin/i' -filename .

This command lists the file names of all photos containing the Berlin tag.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News