jpegoptim
Optimize JPEG files for smaller size
TLDR
Optimise a set of JPEG images, retaining all associated data
Optimise JPEG images, stripping all non-essential data
Force the output images to be progressive
Force the output images to have a fixed maximum filesize
SYNOPSIS
jpegoptim [OPTION ...] [FILE ...]
PARAMETERS
-h, --help
Display help message and exit.
-V, --version
Output version information and exit.
-o, --overwrite
Replace input file with optimized version.
-n, --noaction
Dry run: print actions without optimizing.
-q, --quiet
Suppress progress indicators.
-v, --verbose
Verbose output (repeat for more detail).
-s, --strip-all
Strip all metadata (EXIF, IPTC, XMP, ICC, etc.).
--strip-com
Strip only COM markers.
--strip-exif
Strip only EXIF markers.
--strip-iptc
Strip only IPTC markers.
--strip-icc
Strip only ICC profiles.
-p, --preserve
Preserve file modification timestamps.
-m<size>, --max=<size>
Resize to max dimensions (e.g., -m1024 for 1024px longest side).
-t<threshold>, --threshold=<threshold>
Quality threshold 1-100 (default 95); lower = more lossy.
-b<suffix>, --backup=<suffix>
Backup originals with suffix (default none).
--stdin
Read JPEG from stdin, write optimized to stdout.
DESCRIPTION
jpegoptim is a powerful command-line tool for optimizing JPEG images on Linux systems. It reduces file sizes losslessly by recompressing the image data using advanced JPEG Huffman table optimization and removing superfluous metadata like EXIF, IPTC, XMP, ICC profiles, and comments. This results in smaller files without any perceptible quality loss, making it ideal for web graphics, backups, and storage optimization.
For more aggressive size reduction, it supports lossy modes via quality thresholds or image resizing. Key features include dry-run previews, backups, stdin/stdout processing, and preservation of timestamps. Widely used in batch scripts for directories of images, it processes files in parallel where possible and reports percentage savings. Typical savings range from 10-50% on unoptimized JPEGs from cameras or editors.
Unlike lossy tools, jpegoptim prioritizes reversibility, leveraging libjpeg for reliable decoding/encoding. It's lightweight, fast, and integrates seamlessly into workflows with tools like ImageMagick.
CAVEATS
May not reduce size on already-optimized JPEGs. Lossy modes (-t<100, -m) alter image irreversibly. Use -n first and backups for irreplaceable files. Progressive JPEGs may lose that feature.
BASIC EXAMPLE
jpegoptim --strip-all --overwrite *.jpg
Optimizes all JPGs in current dir, strips metadata, overwrites originals.
INSTALLATION
Debian/Ubuntu: sudo apt install jpegoptim
Fedora: sudo dnf install jpegoptim
Arch: sudo pacman -S jpegoptim
HISTORY
Originally developed by Mads Aagesen (1991-1996), enhanced and maintained by Klaus Post since 2006. Latest release 1.5.5 (2023) adds better metadata stripping and libjpeg-turbo support. Popular in Linux distros for over 20 years.


