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
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.