Images that contain Exif metadata may reveal when and where a photo was taken and with what device, among other things. While this is usually a desirable feature, it can also be a privacy concern if the images are going to be shared or published online. Exif data also helps inflate file size. In this guide, we’ll see how to remove EXIF data from JPG, JPEG, PNG, and other image files from the Linux command line.
There are quite a few tools available that can remove Exif data, but one we’ve found to work very well is ExifTool. This program can strip Exif metadata without recompressing the image, so there’s no loss in quality. There are a variety of options that can be used with the program, such as exporting a new version of the image (without the Exif data) or simply resaving the image in-place. We’ll show you all the most useful commands below.
Downloading ExifTool
You can download this program from the ExifTool website or use the appropriate command below to install it with your system’s package manager.
Ubuntu, Debian, and Linux Mint:
$ sudo apt install libimage-exiftool-perl
Fedora, AlmaLinux, CentOS, and RHEL:
$ sudo dnf install perl-Image-ExifTool
Arch Linux and Manjaro:
$ sudo pacman -S perl-image-exiftool
ExifTool Command Examples
Once ExifTool has been installed, use some of the example commands below in order to remove Exif data. These commands assume that you’ve already changed directories to where your images files are saved.
Example 1. View all the metadata for an image file by using the following command.
$ exiftool image.jpg
Example 2. Use the -all
option to remove all metadata from a file. This command will save a new copy of your file, with the metadata removed. The original file will be renamed, with “_original” appended to the end of it.
$ exiftool -all= image.jpg
Example 3. If you only want to remove one metadata property, you can overwrite that field with empty data. For example, to remove the title
from the metadata:
$ exiftool -title= image.jpg
Example 4. Use the -EXIF
option to remove Exif data only from a file.
$ exiftool -EXIF= image.jpg
Example 5. Use the -overwrite_original
option to remove all metadata without saving the backup files.
$ exiftool -overwrite_original -all= image.jpg
Example 6. Use the -recurse
option to instruct ExifTool to traverse subdirectories. Specify the name of the directory and it’ll clear the metadata for every image file found inside.
$ exiftool -recurse -all= images-folder
Example 7. Use a wildcard and the following options to clear all metadata for all images and those found inside subdirectories. If you’re wary of using it, omit the -overwrite_original
option.
$ exiftool -overwrite_original -recurse -all= *
Example 8. To see all the other options for ExifTool, check the man page.
$ man exiftool
Also check out our guide on how to losslessly compress JPG images via Linux command line if you want to reduce the file sizes of your pictures without any quality loss.
If i want to remove only one metadata, how I can do it ?
Thanks for the suggestion. We have updated the article to show how to remove a single metadata property (example 3).