baoyu-compress-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Compressor
图片压缩工具
Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp).
使用可用的最佳工具压缩图片(优先级:sips → cwebp → ImageMagick → Sharp)。
Script Directory
脚本目录
Scripts in subdirectory. Replace with this SKILL.md's directory path.
scripts/${SKILL_DIR}| Script | Purpose |
|---|---|
| Image compression CLI |
脚本位于子目录中。将替换为此SKILL.md所在的目录路径。
scripts/${SKILL_DIR}| 脚本 | 用途 |
|---|---|
| 图片压缩CLI工具 |
Preferences (EXTEND.md)
偏好设置(EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
bash
undefined使用Bash检查EXTEND.md是否存在(优先级顺序):
bash
undefinedCheck project-level first
先检查项目级路径
test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project"
test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project"
Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
再检查用户级路径(跨平台:$HOME 在 macOS/Linux/WSL 均适用)
test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "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 preferencetest -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user"
┌────────────────────────────────────────────────────────┬───────────────────┐
│ 路径 │ 位置 │
├────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-compress-image/EXTEND.md │ 项目目录 │
├────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md │ 用户主目录 │
└────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ 结果 │ 操作 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 找到 │ 读取、解析、应用设置 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 未找到 │ 使用默认设置 │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
**EXTEND.md 支持**:默认格式 | 默认质量 | 是否保留原文件偏好Usage
使用方法
bash
npx -y bun ${SKILL_DIR}/scripts/main.ts <input> [options]bash
npx -y bun ${SKILL_DIR}/scripts/main.ts <input> [options]Options
选项
| Option | Short | Description | Default |
|---|---|---|---|
| File or directory | Required | |
| | Output path | Same path, new ext |
| | webp, png, jpeg | webp |
| | Quality 0-100 | 80 |
| | Keep original | false |
| | Process subdirs | false |
| JSON output | false |
| 选项 | 简写 | 描述 | 默认值 |
|---|---|---|---|
| 文件或目录 | 必填 | |
| | 输出路径 | 原路径,新扩展名 |
| | webp, png, jpeg | webp |
| | 质量 0-100 | 80 |
| | 保留原文件 | false |
| | 处理子目录 | false |
| JSON格式输出 | false |
Examples
示例
bash
undefinedbash
undefinedSingle file → WebP (replaces original)
单个文件 → WebP(替换原文件)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
Keep PNG format
保留PNG格式
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png --keep
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png --keep
Directory recursive
递归处理目录
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75
JSON output
JSON格式输出
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json
**Output**:image.png → image.webp (245KB → 89KB, 64% reduction)
undefinednpx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json
**输出示例**:image.png → image.webp (245KB → 89KB, 64% reduction)
undefinedExtension Support
扩展支持
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
通过EXTEND.md进行自定义配置。有关路径和支持的选项,请查看偏好设置部分。