$npx -y skills add JimLiu/baoyu-skills --skill baoyu-compress-imageCompresses 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.
| 1 | # Image Compressor |
| 2 | |
| 3 | Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp). |
| 4 | |
| 5 | ## Script Directory |
| 6 | |
| 7 | 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. |
| 8 | |
| 9 | | Script | Purpose | |
| 10 | |--------|---------| |
| 11 | | `scripts/main.ts` | Image compression CLI | |
| 12 | |
| 13 | ## Preferences (EXTEND.md) |
| 14 | |
| 15 | Check EXTEND.md in priority order — the first one found wins: |
| 16 | |
| 17 | | Priority | Path | Scope | |
| 18 | |----------|------|-------| |
| 19 | | 1 | `.baoyu-skills/baoyu-compress-image/EXTEND.md` | Project | |
| 20 | | 2 | `${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-compress-image/EXTEND.md` | XDG | |
| 21 | | 3 | `$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md` | User home | |
| 22 | |
| 23 | If none found, use defaults. |
| 24 | |
| 25 | **EXTEND.md supports**: Default format, default quality, keep-original preference. |
| 26 | |
| 27 | ## Usage |
| 28 | |
| 29 | ```bash |
| 30 | ${BUN_X} {baseDir}/scripts/main.ts <input> [options] |
| 31 | ``` |
| 32 | |
| 33 | ## Options |
| 34 | |
| 35 | | Option | Short | Description | Default | |
| 36 | |--------|-------|-------------|---------| |
| 37 | | `<input>` | | File or directory | Required | |
| 38 | | `--output` | `-o` | Output path | Same path, new ext | |
| 39 | | `--format` | `-f` | webp, png, jpeg | webp | |
| 40 | | `--quality` | `-q` | Quality 0-100 | 80 | |
| 41 | | `--keep` | `-k` | Keep original | false | |
| 42 | | `--recursive` | `-r` | Process subdirs | false | |
| 43 | | `--json` | | JSON output | false | |
| 44 | |
| 45 | ## Examples |
| 46 | |
| 47 | ```bash |
| 48 | # Single file → WebP (replaces original) |
| 49 | ${BUN_X} {baseDir}/scripts/main.ts image.png |
| 50 | |
| 51 | # Keep PNG format |
| 52 | ${BUN_X} {baseDir}/scripts/main.ts image.png -f png --keep |
| 53 | |
| 54 | # Directory recursive |
| 55 | ${BUN_X} {baseDir}/scripts/main.ts ./images/ -r -q 75 |
| 56 | |
| 57 | # JSON output |
| 58 | ${BUN_X} {baseDir}/scripts/main.ts image.png --json |
| 59 | ``` |
| 60 | |
| 61 | **Output**: |
| 62 | ``` |
| 63 | image.png → image.webp (245KB → 89KB, 64% reduction) |
| 64 | ``` |
| 65 | |
| 66 | ## Extension Support |
| 67 | |
| 68 | Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. |