Compressing images
The core job of imgsqz is making images smaller. This guide covers the quality knob, lossless modes, and tips for squeezing each format.
The quality knob
Section titled “The quality knob”-q, --quality takes an integer from 1 to 100. Lower means smaller files
and more compression artifacts; higher means larger files and better fidelity.
The default is 80.
# Aggressive — small files, visible artifacts at close inspectionimgsqz photo.jpg -q 50
# Default — a strong balance for most web imageryimgsqz photo.jpg -q 80
# High fidelity — larger files, near-original qualityimgsqz photo.jpg -q 92Recommended starting points
Section titled “Recommended starting points”| Goal | Format | Quality |
|---|---|---|
| Photographic web images | webp | 75 |
| Smallest modern format | avif | 50–55 |
| Maximum compatibility | jpg | 80 |
| Screenshots / UI / text | png (lossless) or webp --lossless | — |
| Flat-color graphics, logos | png | 80 |
Compress without converting
Section titled “Compress without converting”To shrink a JPG and keep it a JPG, just set the format to match (or rely on the default for JPG sources):
# Re-encode a JPG at quality 75 (mozjpeg makes it smaller than most originals)imgsqz big.jpg -f jpg -q 75 --no-timestamp -o big.jpgFor PNG-to-PNG, lower quality enables palette quantization for big wins on graphics:
imgsqz logo.png -f png -q 70Lossless compression
Section titled “Lossless compression”--lossless switches WebP, AVIF and PNG into a mode that reconstructs every
pixel exactly — ideal for screenshots, diagrams, and anything with sharp text.
# Lossless WebP — pixel-perfect, still smaller than PNG for many imagesimgsqz screenshot.png -f webp --lossless
# Lossless AVIFimgsqz diagram.png -f avif --losslessGrayscale for extra savings
Section titled “Grayscale for extra savings”If color isn’t needed, --grayscale drops the chroma channels and shrinks the
file further:
imgsqz scan.jpg --grayscale -q 80Great for document scans, line art, and black-and-white photography.
Reading the savings report
Section titled “Reading the savings report”imgsqz prints the before/after for every file:
photo.jpg → photo_20260611_132517.jpg 3.10 MB → 488.21 KB (↓ 84.6%)↓ 84.6%— the output is 84.6% smaller than the input.↑ 12.0%— the output is 12% larger (can happen when re-encoding an already-optimized file, or with lossless modes). If you see this, try a lower quality, a different format, or leave the original as-is.
A quick comparison workflow
Section titled “A quick comparison workflow”Produce several candidates and compare sizes, then keep the winner:
for q in 50 65 80; do imgsqz photo.jpg -f webp -q $q -o "out/photo-q$q.webp"donels -lhS out/foreach ($q in 50,65,80) { imgsqz photo.jpg -f webp -q $q -o "out/photo-q$q.webp"}Get-ChildItem out\ | Sort-Object LengthNext: Converting formats.