CLI Tool

leano-cli

for when you'd rather stay in the terminal than open another browser tab. one command, whole directory, done.

npx leano-cli ./public --format webp --quality 80

install

global install (so you can run it anywhere)

npm install -g leano-cli

or just npx it — no install needed

npx leano-cli <input> [options]

requires Node ≥ 18. works on linux, mac, windows. sharp ships pre-built binaries so there's no native compile step.

options

FlagDefaultWhat it does
-f, --format <format>webpOutput format: webp | avif | both
-q, --quality <number>80Compression quality 1–100
--losslessfalseEnable lossless compression
--max-width <px>Maximum output width (no upscaling)
--max-height <px>Maximum output height (no upscaling)
-o, --out <path><input>-optimizedOutput directory
--in-placefalseReplace source directory safely via temp dir
-c, --concurrency <n>autoParallel jobs (cap: webp 16 / both 12 / avif 8)
--quietfalseNo per-file rows (spinner + summary only)
--dry-runfalseList planned outputs only
-h, --helpShow help
-V, --versionShow version

examples

the default — WebP at quality 80

leano-cli ./images

both WebP and AVIF in one go

leano-cli ./images --format both --quality 75

resize while converting (great for hero images)

leano-cli ./public/photos --format webp --max-width 1920 --quality 85

lossless WebP — perfect quality, still smaller

leano-cli ./assets --format webp --lossless

output to a different directory

leano-cli ./src/images --format avif --out ./dist/images

replace in-place — safe, rolls back on failure

leano-cli ./public --format webp --in-place

what the output looks like

leano-cli v1.0.2
  Input:   /home/user/project/public/images
  Output:  /home/user/project/public/images-optimized
  Format:  both  Quality: 80
  Files:   42 images found → 84 outputs

File                                   Original    Converted   Savings
───────────────────────────────────────────────────────────────────────
  hero.webp                               1.2 MB       149 KB      88%
  hero.avif                               1.2 MB       218 KB      82%
  icons/logo.webp                          45 KB        12 KB      73%
  icons/logo.avif                          45 KB         9 KB      80%
───────────────────────────────────────────────────────────────────────

✔ 84 files converted
✔ 56.2 MB → 9.1 MB (84% saved)

Output: /home/user/project/public/images-optimized

a few things worth knowing

ExtensionWhat happens
.jpg / .jpegre-encoded via sharp
.pngre-encoded via sharp
.webp / .avifcopied as-is — no re-encoding

--in-place is actually safe

  1. everything converts to a temp directory first.
  2. only if every single file succeeds, the source gets swapped out.
  3. if anything fails, your originals are completely untouched. temp dir is cleaned up.

want this to run automatically on every PR?

the GitHub workflow does exactly that — zero config after setup.

View Workflow docs