$npx -y skills add ECNU-ICALK/AutoSkill --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. Replace `${SKILL_DIR}` with this SKILL.md's directory path. |
| 8 | |
| 9 | | Script | Purpose | |
| 10 | |--------|---------| |
| 11 | | `scripts/main.ts` | Image compression CLI | |
| 12 | |
| 13 | ## Preferences (EXTEND.md) |
| 14 | |
| 15 | Use Bash to check EXTEND.md existence (priority order): |
| 16 | |
| 17 | ```bash |
| 18 | # Check project-level first |
| 19 | test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project" |
| 20 | |
| 21 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 22 | test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user" |
| 23 | ``` |
| 24 | |
| 25 | ┌────────────────────────────────────────────────────────┬───────────────────┐ |
| 26 | │ Path │ Location │ |
| 27 | ├────────────────────────────────────────────────────────┼───────────────────┤ |
| 28 | │ .baoyu-skills/baoyu-compress-image/EXTEND.md │ Project directory │ |
| 29 | ├────────────────────────────────────────────────────────┼───────────────────┤ |
| 30 | │ $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md │ User home │ |
| 31 | └────────────────────────────────────────────────────────┴───────────────────┘ |
| 32 | |
| 33 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 34 | │ Result │ Action │ |
| 35 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 36 | │ Found │ Read, parse, apply settings │ |
| 37 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 38 | │ Not found │ Use defaults │ |
| 39 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 40 | |
| 41 | **EXTEND.md Supports**: Default format | Default quality | Keep original preference |
| 42 | |
| 43 | ## Usage |
| 44 | |
| 45 | ```bash |
| 46 | npx -y bun ${SKILL_DIR}/scripts/main.ts <input> [options] |
| 47 | ``` |
| 48 | |
| 49 | ## Options |
| 50 | |
| 51 | | Option | Short | Description | Default | |
| 52 | |--------|-------|-------------|---------| |
| 53 | | `<input>` | | File or directory | Required | |
| 54 | | `--output` | `-o` | Output path | Same path, new ext | |
| 55 | | `--format` | `-f` | webp, png, jpeg | webp | |
| 56 | | `--quality` | `-q` | Quality 0-100 | 80 | |
| 57 | | `--keep` | `-k` | Keep original | false | |
| 58 | | `--recursive` | `-r` | Process subdirs | false | |
| 59 | | `--json` | | JSON output | false | |
| 60 | |
| 61 | ## Examples |
| 62 | |
| 63 | ```bash |
| 64 | # Single file → WebP (replaces original) |
| 65 | npx -y bun ${SKILL_DIR}/scripts/main.ts image.png |
| 66 | |
| 67 | # Keep PNG format |
| 68 | npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png --keep |
| 69 | |
| 70 | # Directory recursive |
| 71 | npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75 |
| 72 | |
| 73 | # JSON output |
| 74 | npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json |
| 75 | ``` |
| 76 | |
| 77 | **Output**: |
| 78 | ``` |
| 79 | image.png → image.webp (245KB → 89KB, 64% reduction) |
| 80 | ``` |
| 81 | |
| 82 | ## Extension Support |
| 83 | |
| 84 | Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. |