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.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.