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
| Flag | Default | What it does |
|---|---|---|
-f, --format <format> | webp | Output format: webp | avif | both |
-q, --quality <number> | 80 | Compression quality 1–100 |
--lossless | false | Enable lossless compression |
--max-width <px> | — | Maximum output width (no upscaling) |
--max-height <px> | — | Maximum output height (no upscaling) |
-o, --out <path> | <input>-optimized | Output directory |
--in-place | false | Replace source directory safely via temp dir |
-c, --concurrency <n> | auto | Parallel jobs (cap: webp 16 / both 12 / avif 8) |
--quiet | false | No per-file rows (spinner + summary only) |
--dry-run | false | List planned outputs only |
-h, --help | — | Show help |
-V, --version | — | Show 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
| Extension | What happens |
|---|---|
.jpg / .jpeg | re-encoded via sharp |
.png | re-encoded via sharp |
.webp / .avif | copied as-is — no re-encoding |
--in-place is actually safe
- everything converts to a temp directory first.
- only if every single file succeeds, the source gets swapped out.
- 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