jpegtran Command to Remove Metadata from jpeg and jpg Image Files

Tadashi Shigeoka ·  Sat, March 21, 2020

I’ll introduce how to use the jpegtran command to remove metadata from .jpeg and .jpg image files.

Linux

Background: Want to Remove Metadata from Image Files

JPEG images may contain Exif metadata that doesn’t affect the display, so we’ll remove this to optimize images without degrading quality.

Remove Image Metadata with jpegtran

jpegtran Installation [macOS Edition]

brew install jpeg

jpegtran Command Options Explanation

To remove metadata with the jpegtran command, use the following options:

-copy none Remove all metadata from jpeg files

-optimize Optimize Huffman tables

-outfile Specify the output destination of the file

Remove Metadata from a Specific Image

jpegtran -copy none -optimize -outfile /path/to/target.jpg /path/to/target.jpg

Batch Remove Image Metadata

find /path/to/dir/ -name "*.jpg" -type f -exec jpegtran -copy none -optimize -outfile {} {} \\;

That’s all from the Gemba.

Reference Information