Keep learning
- Core concepts — how defaults, naming and safety work
- Compressing images — quality vs. size, per format
- Converting formats — choosing the right format
- CLI reference — every flag in one place
This page takes you from a fresh install to a handful of real optimizations.
Install the CLI (or use npx to skip this).
npm install -g @wdalhaj/imgsqzSqueeze your first image. The default command writes an optimized JPG next to the source, with a timestamp suffix so nothing is overwritten:
imgsqz photo.png/Users/you/photo.png → /Users/you/photo_20260611_132517.jpg 2.41 MB → 412.08 KB (↓ 83.3%)Convert to a modern format. Add -f webp (or avif) for much smaller
files at the same visual quality:
imgsqz photo.png -f webp -q 70Resize while you’re at it. Cap the width at 800px (height scales automatically):
imgsqz photo.png -f webp -q 70 --width 800Do a whole folder. Pass a glob — your shell expands it and imgsqz processes each file:
imgsqz *.png -f webp -q 75Every processed file prints a three-line report (unless you pass --quiet):
input/path.png ← the source file → output/path.webp ← where the result was written 2.41 MB → 412.08 KB (↓ 83.3%) ← before → after (↓ percentage smaller)An ↑ arrow instead of ↓ means the output got larger (rare, but possible
with already-optimized sources or lossless modes).
# 1. Default: optimized JPG next to the sourceimgsqz image.png
# 2. Convert PNG → WebP at quality 60imgsqz image.png -f webp -q 60
# 3. Resize to 800px wide, output AVIFimgsqz image.jpg -f avif --width 800
# 4. Pick an exact output pathimgsqz image.jpg -o out/thumb.webp -f webp -q 70
# 5. Overwrite the original in place, safelyimgsqz image.jpg --replace -q 80Keep learning