High-performance CLI image compressor using sharp and libvips
npm install micropng-cliA high-performance, local-first CLI image compressor built with Node.js and libvips (via sharp). Designed for developers who need fast, reliable, and recursive image optimization without sending data to a cloud service.



- Blazing Fast: Uses parallel processing with smart concurrency control to saturate your CPU without crashing.
- Deeply Recursive: Scans folders and subfolders, maintaining your directory structure perfectly.
- Safety First: Implements atomic overwrites using the --replace flag—original files are only replaced if the compressed version is actually smaller.
- Universal Formats: Full support for JPEG, PNG, WebP, and AVIF conversion and compression.
- Local-First: No data ever leaves your machine. Your privacy is guaranteed.
- Smarter Scanning: Native support for ignore patterns to skip node_modules, .git, or specific assets.
- Metadata Control: Choose whether to strip or keep EXIF information (GPS, camera settings, etc.).
micropng-cli command anywhere:bash
npm install -g micropng-cli
`$3
Use npx to run it instantly without cluttering your system:
`bash
npx micropng-cli --help
`---
🛠 Usage Examples
$3
Compress a single file and save it as a new file:
`bash
micropng-cli input.png --output optimized.png
`$3
Optimize an entire directory and maintain the structure in an output folder:
`bash
micropng-cli ./raw-assets --output ./dist/assets --recursive
`$3
The most popular way to use MicroPng. This will search through your project and optimize all images, replacing them only if size is saved:
`bash
micropng-cli ./src --recursive --replace --quality 85
`$3
Convert all images in a folder to WebP for modern web performance:
`bash
micropng-cli ./images --format webp --output ./webp-bundle --recursive
`$3
Ignore specific directories or patterns while processing:
`bash
micropng-cli . --recursive --replace --ignore "node_modules/" "/previews/*" ".tmp"
`---
⚙️ Options
| Option | Alias | Description | Default |
| :--- | :--- | :--- | :--- |
|
--output | -o | Target directory for compressed files | (Current Dir) |
| --recursive | -r | Deep scan folders and subfolders | false |
| --replace | | Replace originals (Atomic safety enabled) | false |
| --quality | -q | Compression quality (1-100) | 80 |
| --format | -f | Output format (jpeg, png, webp, avif) | (Source Ext) |
| --concurrency | -c | Max simultaneous tasks | 5 |
| --ignore | -i | Patterns to exclude (supports multiple) | - |
| --keep-metadata| | Preserves EXIF/GPS/IPTC data | false` |---
- Changelog: See what's new in each version.
- Contributing: Learn how to set up the dev environment and add new features.
- Distribution: Details on the build and release pipeline.
MIT © Sahil Fruitwala