B

baoyu-compress-image

Verified

by JimLiu · Updated Apr 16, 2026

opus
294in5.5Kout
$0.552m 49s

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.

imagecompressionwebppngoptimizationconversion

See It In Action

1 turns·claude
The project codebase is in your current working directory. Explore the files to understand the code before making changes. docs ship today — pls compress everything in docs/assets/screenshots, keep the pngs, follow the repo defaults, and give me the optimized images plus a size-savings summary

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

FileOriginalCompressedReduction
analytics-report.png688 KB299 KB56%
checkout-flow.png554 KB192 KB65%
dashboard-overview.png543 KB211 KB61%
product-catalog.png731 KB308 KB57%
user-profile.png584 KB241 KB58%
Total3,100 KB1,251 KB60%

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.

Claude Sonnet 4.6

External Tools

ToolType
bunbinary
npxbinary

Permissions

ScopeDescription
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.

ScriptPurpose
scripts/main.tsImage 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

OptionShortDescriptionDefault
<input>File or directoryRequired
--output-oOutput pathSame path, new ext
--format-fwebp, png, jpegwebp
--quality-qQuality 0-10080
--keep-kKeep originalfalse
--recursive-rProcess subdirsfalse
--jsonJSON outputfalse

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.