To remove EXIF data on Linux, install ExifTool and run exiftool -all= photo.jpg: it deletes EXIF, XMP, IPTC and other metadata blocks without re-encoding the image, and keeps a backup named photo.jpg_original. mat2, ImageMagick and jhead can do the job too, but each behaves differently with image quality, color profiles and rotation, so it pays to know which one you are using.

Which Linux tool should you use to remove EXIF data?

All four tools below are packaged by the major distributions. The important differences are whether they rewrite the pixels, which formats they handle, and what happens to the ICC color profile (the small block that tells viewers how to display colors).

ToolImage formatsRe-encodes the image?ICC profileBest for
ExifToolJPEG, PNG, WebP, TIFF, HEIC and many moreNoRemoved by -all=, but easy to keepPrecise, lossless cleaning and scripting
mat2JPEG, PNG, WebP, GIF, TIFF, plus documents, audio, archivesYes, by defaultLost when the image is re-renderedMixed privacy cleanup (photos and documents)
ImageMagickAlmost everythingYes, alwaysRemoved by -stripWhen you also resize or convert
jheadJPEG onlyNoCheck the resultQuick JPEG-only edits, lossless rotation

If you only want one tool, choose ExifTool. It is the reference implementation that most other metadata software is compared against, and it does not degrade your photos. The rest of this guide shows how to use each tool correctly, including the traps.

Install ExifTool, mat2, ImageMagick and jhead

On Debian, Ubuntu, Linux Mint and other Debian-based systems:

sudo apt install libimage-exiftool-perl mat2 imagemagick jhead

ExifTool's package name is the confusing one. On Fedora it is perl-Image-ExifTool and on Arch Linux perl-image-exiftool. Other package names vary slightly between distributions, so search your package manager if one is not found. You can also download ExifTool directly from exiftool.org; it is a Perl script and runs on any distribution.

ImageMagick 7 uses the magick command. Many long-term-support distributions still ship ImageMagick 6, where the same operations use convert and mogrify instead. Run magick -version or convert -version to see which one you have.

Start by looking at what the file contains. The -a option shows duplicate tags, -G1 shows the group each tag lives in (EXIF, GPS, XMP, IPTC, ICC_Profile and so on), and -s prints short tag names:

exiftool -a -G1 -s photo.jpg

Look for tags such as GPSLatitude, Make, Model, SerialNumber, DateTimeOriginal and a ThumbnailImage. Then delete everything:

exiftool -all= photo.jpg

ExifTool renames the untouched file to photo.jpg_original and writes the cleaned version under the original name. The compressed image data is copied as-is, so there is no quality loss.

Keep the colors and the rotation

A bare -all= removes two things you may want to keep. The first is the ICC profile: without it, photos from phones that shoot in Display P3 can look duller. The second is the Orientation tag: many cameras save the pixels sideways and rely on this tag to display them upright, so deleting it can leave your photo rotated. ExifTool can delete everything and then copy those items back from the same file (@ means "this file"):

exiftool -all= -tagsfromfile @ -colorspacetags -orientation photo.jpg

ColorSpaceTags is a built-in ExifTool shortcut for the ICC profile plus the few standard tags that describe color space, documented on the ExifTool shortcuts page. Neither the profile nor the orientation flag identifies you. Our guides on ICC color profiles and EXIF orientation explain why these two are worth keeping.

Clean a whole folder

Add -r to recurse into subfolders, limit the run to image types with -ext, and use -overwrite_original if you do not want backup files (only do this on copies):

exiftool -r -overwrite_original -all= -tagsfromfile @ -colorspacetags -orientation \
  -ext jpg -ext jpeg -ext png -ext webp ~/Pictures/to-share

For the full list of ExifTool options, including removing only GPS or keeping your copyright notice, see our ExifTool cheat sheet.

Clean images with mat2

mat2 (Metadata Anonymisation Toolkit 2) is designed for people who share files under pressure, which is why it is included in the Tails operating system. It handles images, PDFs, office documents, audio files and archives with one command. To see what it detects without changing anything:

mat2 --show photo.jpg

To clean the file:

mat2 photo.jpg

mat2 never overwrites by default. It writes a new file with cleaned inserted before the extension, here photo.cleaned.jpg. Use --inplace to replace the original instead (there is no backup), and mat2 --list to see the supported formats on your version.

The trade-off: mat2 re-renders your photo

In its default mode, mat2 does not just delete metadata blocks. For JPEG and WebP it decodes the image with the GdkPixbuf library, applies the orientation to the pixels, and saves a brand-new file; PNG files are redrawn through Cairo. Nothing from the old file structure survives, which is thorough. The cost is that JPEGs are compressed a second time with the library's default settings (GdkPixbuf's default JPEG quality is 75), so the file can lose visible detail, and the ICC profile is not carried over.

The --lightweight (-L) option avoids altering the image data, but the mat2 documentation says plainly that it removes only some metadata. If image quality matters, ExifTool is the better tool for photos; mat2 shines when you need to clean a folder of mixed files. Our article on removing metadata without losing quality explains why recompression adds up.

Prefer a window to a terminal? Metadata Cleaner is a GNOME app built on mat2. It is available on Flathub and, in Tails, under Apps > Accessories > Metadata Cleaner. It makes the same trade-offs as mat2.

Strip metadata with ImageMagick

ImageMagick's -strip option removes all profiles and comments, plus PNG text and color chunks. With ImageMagick 7:

magick photo.jpg -auto-orient -strip clean.jpg

On ImageMagick 6, replace magick with convert. Put -auto-orient first: it rotates the pixels according to the Orientation tag, so the photo stays upright once the tag is gone.

Three things to know before you rely on it:

  • It always re-encodes. ImageMagick decodes the image and writes a new one. For JPEG, the default quality is the estimated quality of the input (or 92 if it cannot be determined), so each pass loses a little. Use it when you are resizing or converting anyway.
  • It removes the ICC profile. To keep only the color profile, use the profile pattern syntax instead of -strip: magick photo.jpg -auto-orient +profile "!icc,*" clean.jpg. Check the result, since comments are not profiles and are handled separately.
  • mogrify overwrites files. magick mogrify -strip *.jpg rewrites every JPEG in place. Add -path cleaned (after creating the cleaned folder) to write copies instead.

Remove JPEG metadata with jhead

jhead is a small, fast program for JPEG files only. Its -purejpg option deletes every JPEG section that is not needed to render the image. It is a combination of -de (delete the EXIF header), -dc (delete the comment) and -du (delete sections jhead does not recognize). Because it edits files in place without a backup, work on copies:

jhead -autorot *.jpg
jhead -purejpg *.jpg

The first command fixes rotation before the orientation tag disappears. It uses the separate jpegtran program, which rotates JPEG data losslessly, then resets the tag to "normal". For finer control, -di deletes only IPTC, -dx only XMP, and -dt only the embedded thumbnail. jhead's documentation does not describe how it treats ICC profiles, so check the output with ExifTool if color accuracy matters to you.

Batch loops for tools that work file by file

ExifTool and mat2 accept many files or folders at once, so you rarely need a loop for them. A loop is useful with ImageMagick when you want cleaned copies in a separate folder while the originals stay untouched:

mkdir -p cleaned
for f in *.jpg *.jpeg *.png *.webp; do
  [ -e "$f" ] || continue
  magick "$f" -auto-orient -strip "cleaned/$f"
done

The [ -e "$f" ] || continue line skips patterns that match no file. To run mat2 on every image in a directory tree, including subfolders, let find pass the files in batches:

find ~/to-share -type f \( -iname '*.jpg' -o -iname '*.jpeg' \
  -o -iname '*.png' -o -iname '*.webp' \) -exec mat2 {} +

With ExifTool, the -o option writes cleaned copies to another directory in one command; a trailing slash tells ExifTool the name is a folder, and it creates it if needed:

exiftool -all= -tagsfromfile @ -colorspacetags -orientation -o ~/share-clean/ ~/Pictures/to-share

Our guide to removing metadata from multiple photos at once compares these approaches with desktop and online options.

Verify the result before you share

Run ExifTool on the cleaned file:

exiftool -a -G1 -s cleaned/photo.jpg

A clean file shows tags from the System group (file name, size, dates on your disk), the File group (dimensions, encoding), Composite values calculated by ExifTool, and only what you chose to keep, such as ICC_Profile tags and Orientation. If you kept orientation and color tags, a tiny EXIF block remains with Orientation, ColorSpace and perhaps InteropIndex, and nothing else. If you still see GPS, XMP-* or IPTC groups, camera tags like Make and Model, or maker note groups named after the camera brand (such as Apple, Canon or Samsung), something was missed. To check only for location across a whole folder, list the files that still have coordinates:

exiftool -r -if '$GPSLatitude' -p '$Directory/$FileName' ~/share-clean

No output means no file in that folder still has a GPS latitude. Our article on checking that metadata was really removed covers verification on other systems too.

No terminal at hand?

On a shared computer, a live USB session, or a laptop where you cannot install packages, you can remove metadata online from Firefox or Chromium. Our tool accepts JPEG, PNG and WebP, up to 10 images at a time, keeps the pixels untouched in its default mode, preserves only the color profile and orientation flag, and deletes uploaded files automatically 10 minutes after processing. Processing happens on our server, so if you prefer that files never leave your machine, the command-line tools above are the right choice.

Linux EXIF removal checklist

  1. Work on copies, not your only originals.
  2. Inspect the file with exiftool -a -G1 -s to see what is there.
  3. For photos, use exiftool -all= -tagsfromfile @ -colorspacetags -orientation.
  4. Use mat2 when you are also cleaning PDFs, office files or audio, and accept that images are re-rendered.
  5. Use ImageMagick -auto-orient -strip only when you are resizing or converting anyway.
  6. Verify the output, then delete backup files such as *_original once you are satisfied.
  7. Look at the picture itself: house numbers, screens and reflections are not metadata, and no tool removes them.