@puntoycoma/bulki
The image optimizer that works the way you do — interactively, automatically, or as a tool your AI editor calls for you.
Compress, resize, and convert JPEG, PNG, WebP, GIF, and AVIF images in bulk. Powered by Sharp (libvips) — 4-5x faster than ImageMagick.
Free. Open source. No API keys. Runs 100% locally.
npm install -g @puntoycoma/bulki
At a glance
| Feature | What it does | Command |
|---|---|---|
| Compress | Optimize images with quality, format, and resize control | bulki compress ./photos -f webp -q 80 |
| Interactive | Guided menu with presets — no flags to memorize | bulki |
| Watch | Monitor a folder and auto-optimize new images | bulki watch ./uploads -f webp |
| Pipe | Read from stdin, write to stdout — compose with any tool | cat img.jpg | bulki pipe -f webp > out.webp |
| Git hook | Auto-optimize images on every commit | bulki hook install |
| MCP server | Let AI editors (Claude Code, Cursor) call bulki directly | bulki mcp |
| JSON output | Machine-readable results for scripts and CI/CD | bulki compress ./imgs --json |
| Size budget | Fail if any image exceeds a size limit | bulki compress ./imgs --max-size 200kb |
Quick start
Interactive mode
bulki
Guided step-by-step mode. Drag a folder (or several images) into the terminal window when it asks
for a path — quotes, escaped spaces and trailing spaces are handled for you. You can also start it
with a path: bulki ~/Desktop/My\ Photos.
Presets:
- Web optimized — WebP, quality 80, max 1920px wide
- Social media — JPEG, quality 85, max 1080px wide
- Just make them smaller — same format and size, quality 80
- Custom — you choose format, quality and size
Navigation: Esc goes back one step (nothing you chose is lost), Ctrl+C quits. A wrong path or number is rejected in place so you can fix it. Before starting you get a summary where you can change the images, settings or output folder; afterwards you can open the output folder or run again with different settings.
CLI mode
bulki compress ./photos # → ./bulki-output
bulki compress ./photos -o ./web -f webp -q 80 # convert to WebP into ./web
bulki compress "My Photos" -o "Web Ready" -r 1920
bulki compress hero.png logo.png -f avif # several files at once (globs work too)
Compress
Optimize files and/or folders. Originals are never modified — optimized copies are written to the output folder, mirroring the folder structure.
bulki compress <paths...> [options]
| Option | Alias | Description | Default |
|---|---|---|---|
--output <dir> | -o | Folder where optimized images are written | ./bulki-output |
--quality <n> | -q | Output quality (1-100) | 70 |
--format <fmt> | -f | jpeg, png, webp, gif, avif | keep original |
--resize <width> | -r | Max width in pixels (never enlarges) | original |
--concurrency <n> | Images processed in parallel (1-32) | CPU count (max 8) | |
--exclude <names...> | Folder names to skip | none | |
--dry-run | Show what would be written, without writing | false | |
--verbose | One line per file | false | |
--json | Machine-readable JSON output | false | |
--max-size <size> | Fail if output exceeds limit (e.g., 200kb, 1mb) | none |
The path you want to optimize is the argument (bulki compress <path>); -o is only where the
results go. Paths with spaces must be quoted ("My Photos") or escaped (My\ Photos) — or just
drag the folder into the terminal.
Upgrading from 3.0?
-d/--destination <dir>and--output-folder <name>still work (-d x→x/bulki-output,-d x -o name→x/name) but are deprecated in favor of-o <dir>.
Behaviour worth knowing:
- Previous
bulki-outputfolders inside the source are skipped, so running twice doesn't nest outputs. - If re-encoding would make an image bigger, the original bytes are copied instead.
- EXIF orientation is applied (phone photos won't come out sideways); transparent PNG → JPEG gets a white background.
photo.jpgandphoto.pngconverted to WebP becomephoto.webpandphoto-png.webp(nothing is silently overwritten).- HEIC/HEIF photos (iPhone) are converted on macOS.
- A broken image doesn't stop the batch: it's reported at the end and the exit code is
1.
Output preserves your folder structure:
photos/ bulki-output/
vacation/ -> vacation/
beach.jpg beach.jpg
sunset.png sunset.png
Examples
# Optimize for web: WebP, quality 80, max 1920px
bulki compress ./public -f webp -q 80 -r 1920
# Preview what would be processed without writing anything
bulki compress ./uploads --dry-run
# Get JSON results for a script
bulki compress ./images --json
# Fail in CI if any image exceeds 200 KB
bulki compress ./assets --max-size 200kb
JSON output
bulki compress ./images --json
{
"files": [
{
"input": "photo.jpg",
"output": "bulki-output/photo.webp",
"originalSize": 2400000,
"newSize": 680000,
"reduction": 72,
"format": "webp"
}
],
"summary": {
"totalFiles": 1,
"totalOriginalSize": 2400000,
"totalNewSize": 680000,
"totalReduction": 72,
"errors": 0
}
}
Watch
Monitor a directory. Every time a new image appears, bulki optimizes it automatically. Runs until you press Ctrl+C.
bulki watch <directory> [options]
Same options as compress: --output, --quality, --format, --resize. Files are processed once
they stop changing (large copies aren't read half-written), and edits to an existing image are
re-optimized.
Examples
# Watch uploads and convert everything to WebP
bulki watch ./uploads -f webp -q 80
# Watch with resize, output to a different folder
bulki watch ./photos -r 1920 -q 85 -o ./optimized
Use cases
- Photographers — import photos from camera to a folder, get optimized versions automatically
- Designers — export from Figma or Sketch, images optimize as they save
- Upload servers — monitor
/var/uploadsand serve optimized versions from/var/optimized - Content teams — shared folder where anyone drops images and they come out ready for web
Pipe
Read an image from stdin, optimize it, write the result to stdout. No files on disk.
bulki pipe -f <format> [-q quality] [-r width]
Examples
# Download and optimize in one command
curl -s https://example.com/photo.jpg | bulki pipe -f webp -q 80 > photo.webp
# Convert format on the fly
cat input.png | bulki pipe -f avif -q 70 > output.avif
# Optimize and upload to S3 without saving locally
cat photo.jpg | bulki pipe -f webp -r 800 | aws s3 cp - s3://bucket/photo.webp
Use cases
- CI/CD pipelines — optimize images during build without temp files
- Shell scripts — compose with
curl,aws,gsutil,scp, or any Unix tool - Webhooks — receive an image from an HTTP request, optimize, forward
Git hook
Install a pre-commit hook that auto-optimizes every image you commit. One command. Works for the entire team.
bulki hook install # add the hook
bulki hook uninstall # remove it
How it works
- You run
bulki hook installonce in your repo - Every time someone runs
git commitwith staged image files (JPEG, PNG, WebP, GIF, AVIF), bulki optimizes them before the commit completes - The optimized version replaces the original in the commit
- No manual step — it just works
Use cases
- Teams — ensure no one ever commits unoptimized images
- Repository health — keep your repo lean without manual work
- Faster CI/CD — smaller images in the repo = faster clones, builds, and deploys
MCP server (AI editor integration)
bulki includes a built-in MCP server. AI coding assistants call bulki directly — no shell commands, no copy-paste.
Runs 100% locally. No API keys. No internet required.
Works with Claude Code, Cursor, Windsurf, Cline, and any MCP-compatible editor.
bulki mcp
Setup
Add to your editor's MCP config:
Claude Code (~/.claude.json or project .mcp.json):
{
"mcpServers": {
"bulki": {
"command": "npx",
"args": ["@puntoycoma/bulki", "mcp"]
}
}
}
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"bulki": {
"command": "npx",
"args": ["@puntoycoma/bulki", "mcp"]
}
}
}
Then ask your AI:
"Optimize all images in the project for web" "Convert the PNG files in /public to WebP" "Check if any image in /assets is larger than 200kb"
Available tools
| Tool | Description |
|---|---|
compress | Optimize images with format, quality, resize, and size budget options |
detect | Identify if a file is an image and return its format |
Integration examples
npm scripts
{
"scripts": {
"images": "bulki compress ./src/assets -f webp -q 80",
"images:check": "bulki compress ./public --max-size 200kb --dry-run"
}
}
GitHub Actions
- name: Optimize images
run: npx @puntoycoma/bulki compress ./public -f webp -q 80 --max-size 500kb
CI pipeline with JSON
result=$(bulki compress ./dist/images --json --max-size 300kb)
echo "$result" | jq '.summary.totalReduction'
Supported formats
| Format | Compress | Convert to | Convert from |
|---|---|---|---|
| JPEG | yes | yes | yes |
| PNG | yes | yes | yes |
| WebP | yes | yes | yes |
| GIF (animated) | yes | yes | yes |
| AVIF | yes | yes | yes |
Requirements
- Node.js >= 20.9
FAQ
How do I convert images to WebP from the command line?
bulki compress ./images -f webp -q 80
What's the best free alternative to TinyPNG?
bulki — runs locally, no file limits, no API keys. bulki compress ./photos -q 80
How do I optimize images for web performance?
bulki compress ./public -f webp -q 80 -r 1920 --max-size 500kb
How do I auto-optimize images in my project?
bulki hook install for git commits, or bulki watch ./uploads for a live folder.
Can AI editors optimize images? Yes. Add bulki as an MCP server to Claude Code, Cursor, or Windsurf. Ask: "optimize the images in /public".
What formats does bulki support? JPEG, PNG, WebP, GIF (animated), and AVIF. Compression and conversion between all formats.
Is imagemin still maintained? No. imagemin and its plugins are deprecated. bulki is a modern, maintained alternative.
License
AGPL-3.0 — free to use, modify, and distribute. All derivatives must remain open source under the same license. See LICENSE for details.
Contributing
Issues and PRs welcome at github.com/PuntoyComaTech/bulki.