baoyu-compress-image
Verifiedby JimLiu · Updated Apr 16, 2026
Compresses images to WebP (default) or PNG with automatic tool selection. Use when user asks to "compress image", "optimize image", "convert to webp", or reduce image file size.
See It In Action
Let me explore the project structure and find the images to compress.
Let me check for repo defaults (EXTEND.md) and then compress all 5 images.
Repo defaults: format=webp, quality=85, keep=true. User wants PNG format instead. I'll compress all 5 images with -f png -q 85 --keep.
The skill scripts aren't downloaded yet. Let me use the skill tool which handles this properly.
The skill only has the SKILL.md — no scripts directory. The SKILL.md mentions it uses sips → cwebp → ImageMagick → Sharp as available tools. Since we're on macOS, sips is available natively. Let me compress the images directly using sips, following repo defaults (quality 85, keep originals, PNG format).
sips PNG re-encoding actually increased sizes (PNG is lossless, quality parameter doesn't apply the same way). Let me restore originals and use a proper PNG optimizer.
ImageMagick is available. I'll use it for proper PNG optimization with quality 85.
PNG lossless re-encoding barely helps. Let me install pngquant which does proper lossy PNG compression (perfect for screenshots at quality 85).
Now let me compress all screenshots with pngquant at quality 85.
Excellent results. Let me verify the files and clean up.
All 5 screenshots compressed. Originals preserved as .original.png backups per repo defaults (keep: true).
Size Savings Summary
| File | Original | Compressed | Reduction |
|---|---|---|---|
analytics-report.png | 688 KB | 299 KB | 56% |
checkout-flow.png | 554 KB | 192 KB | 65% |
dashboard-overview.png | 543 KB | 211 KB | 61% |
product-catalog.png | 731 KB | 308 KB | 57% |
user-profile.png | 584 KB | 241 KB | 58% |
| Total | 3,100 KB | 1,251 KB | 60% |
Saved ~1.8 MB total across the 5 images. Used pngquant (lossy PNG, quality 70-85 range per repo default of 85) which gives dramatically better compression than lossless re-encoding while keeping excellent visual fidelity for UI screenshots. Format stays PNG as requested.
External Tools
| Tool | Type |
|---|---|
| bun | binary |
| npx | binary |
Permissions
| Scope | Description |
|---|---|
| filesystem:read | |
| filesystem:write | |
| filesystem:delete | |
| process:spawn |
SKILL.md
Image Compressor
Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp).
Script Directory
Scripts in scripts/ subdirectory. {baseDir} = this SKILL.md's directory path. Resolve ${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bun. Replace {baseDir} and ${BUN_X} with actual values.
| Script | Purpose |
|---|---|
scripts/main.ts | Image compression CLI |
Preferences (EXTEND.md)
Check EXTEND.md existence (priority order):
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user"
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-compress-image/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-compress-image/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md") { "user" }
┌────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/baoyu-compress-image/EXTEND.md │ Project directory │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md │ User home │ └────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ Result │ Action │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Found │ Read, parse, apply settings │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Not found │ Use defaults │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports: Default format | Default quality | Keep original preference
Usage
${BUN_X} {baseDir}/scripts/main.ts <input> [options]
Options
| Option | Short | Description | Default |
|---|---|---|---|
<input> | File or directory | Required | |
--output | -o | Output path | Same path, new ext |
--format | -f | webp, png, jpeg | webp |
--quality | -q | Quality 0-100 | 80 |
--keep | -k | Keep original | false |
--recursive | -r | Process subdirs | false |
--json | JSON output | false |
Examples
# Single file → WebP (replaces original)
${BUN_X} {baseDir}/scripts/main.ts image.png
# Keep PNG format
${BUN_X} {baseDir}/scripts/main.ts image.png -f png --keep
# Directory recursive
${BUN_X} {baseDir}/scripts/main.ts ./images/ -r -q 75
# JSON output
${BUN_X} {baseDir}/scripts/main.ts image.png --json
Output:
image.png → image.webp (245KB → 89KB, 64% reduction)
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
FAQ
What does baoyu-compress-image do?
Compresses images to WebP (default) or PNG with automatic tool selection. Use when user asks to "compress image", "optimize image", "convert to webp", or reduce image file size.
When should I use baoyu-compress-image?
Use it when you need a repeatable workflow that produces image output, code diff.
What does baoyu-compress-image output?
In the evaluated run it produced image output, code diff.
How do I install or invoke baoyu-compress-image?
Ask the agent to use this skill when the task matches its documented workflow.
Which agents does baoyu-compress-image support?
Agent support is inferred from the source, but not explicitly declared.
What tools, channels, or permissions does baoyu-compress-image need?
It uses bun, npx; channels commonly include image, diff; permissions include filesystem:read, filesystem:write, filesystem:delete, process:spawn.
Is baoyu-compress-image safe to install?
Static analysis marked this skill as medium risk; review side effects and permissions before enabling it.
How is baoyu-compress-image different from an MCP or plugin?
A skill packages instructions and workflow conventions; tools, MCP servers, and plugins are dependencies the skill may call during execution.
Does baoyu-compress-image outperform not using a skill?
About baoyu-compress-image
When to use baoyu-compress-image
When you need to reduce image file sizes in a project directory. When you want to convert PNG or other images to WebP in bulk. When you need a local CLI workflow for recursive image optimization.
When baoyu-compress-image is not the right choice
When you need cloud-based image hosting or CDN transformations. When the task is only to inspect images without creating or replacing files.
What it produces
Produces image output and code diff.
