Catalog
jimliu/baoyu-compress-image

jimliu

baoyu-compress-image

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.

global
New~544
v1.0Saved Jul 12, 2026

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 in priority order — the first one found wins:

Priority Path Scope
1 .baoyu-skills/baoyu-compress-image/EXTEND.md Project
2 ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-compress-image/EXTEND.md XDG
3 $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md User home

If none 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.

Files2
2 files · 10.9 KB

Select a file to preview

Overall Score

82/100

Grade

B

Good

Safety

82

Quality

83

Clarity

84

Completeness

76

Summary

Compresses images using tool auto-detection (sips, cwebp, ImageMagick, Sharp) to WebP, PNG, or JPEG. Supports single files or batch directory processing with optional quality control. Uses EXTEND.md for user preferences.

Detected Capabilities

spawn child processesfile read and writedirectory traversalfilesystem operations (rename, delete via file replacement)import and dynamic module loading

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

compress imageoptimize image sizeconvert to webpbatch image compressionreduce image quality

Risk Signals

INFO

File deletion via renameSync during compression (moves original to _original backup, then overwrites original path with compressed)

scripts/main.ts:processFile() lines 98-102
INFO

Recursive directory traversal with no explicit depth limit

scripts/main.ts:collectFiles() lines 108-118
INFO

Child process spawning with external commands (sips, cwebp, convert)

scripts/main.ts:commandExists() and compress functions
INFO

Dynamic module import (Sharp) at runtime

scripts/main.ts:compressWithSharp() line 82

Referenced Domains

External domains referenced in skill content, detected by static analysis.

github.com

Use Cases

  • Reduce image file sizes in projects for faster web performance
  • Batch convert image formats across a directory
  • Optimize media assets with configurable quality settings
  • Preserve original files while creating compressed copies
  • Automate image compression in build or CI/CD workflows

Quality Notes

  • Clear and well-structured TypeScript implementation with strong error handling
  • Sensible compressor fallback chain (sips → cwebp → ImageMagick → Sharp) with platform detection
  • Comprehensive options parsing with validation (quality bounds 0-100, format enum guards)
  • Good output formats: human-readable default and JSON for programmatic use
  • EXTEND.md support for user preferences is documented but file not provided—users must create it manually
  • Missing documentation on: behavior when output file already exists, disk space requirements, supported formats list details
  • Edge case: no validation that output path is writable before compression attempt
  • Quality setting semantics differ per tool (sips uses different encoding than cwebp/ImageMagick)
Model: claude-haiku-4-5-20251001Analyzed: Jul 12, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use jimliu/baoyu-compress-image in your dev environment

Command Palette

Search for a command to run...