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.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.