Skip to content

Quick start

This page takes you from a fresh install to a handful of real optimizations.

  1. Install the CLI (or use npx to skip this).

    Terminal window
    npm install -g @wdalhaj/imgsqz
  2. Squeeze your first image. The default command writes an optimized JPG next to the source, with a timestamp suffix so nothing is overwritten:

    Terminal window
    imgsqz photo.png
    /Users/you/photo.png
    → /Users/you/photo_20260611_132517.jpg
    2.41 MB → 412.08 KB (↓ 83.3%)
  3. Convert to a modern format. Add -f webp (or avif) for much smaller files at the same visual quality:

    Terminal window
    imgsqz photo.png -f webp -q 70
  4. Resize while you’re at it. Cap the width at 800px (height scales automatically):

    Terminal window
    imgsqz photo.png -f webp -q 70 --width 800
  5. Do a whole folder. Pass a glob — your shell expands it and imgsqz processes each file:

    Terminal window
    imgsqz *.png -f webp -q 75

Every 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).

Terminal window
# 1. Default: optimized JPG next to the source
imgsqz image.png
# 2. Convert PNG → WebP at quality 60
imgsqz image.png -f webp -q 60
# 3. Resize to 800px wide, output AVIF
imgsqz image.jpg -f avif --width 800
# 4. Pick an exact output path
imgsqz image.jpg -o out/thumb.webp -f webp -q 70
# 5. Overwrite the original in place, safely
imgsqz image.jpg --replace -q 80