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%)
undefinedExtension Support
扩展支持
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。有关路径和支持选项,请查看偏好设置部分。
OpenClaw Migration Notes
OpenClaw迁移说明
- Migration mode: OpenClaw native first
- Preserved directories:
- scripts: yes
- references: no
- prompts: no
- External dependencies: bun
- Risk level: low
- Environment variables (detected):
HOME - Config compatibility: keep original behavior and add OpenClaw-compatible path in runtime wrappers when needed.
.baoyu-skills/<skill>/EXTEND.md
- 迁移模式:优先使用OpenClaw原生方式
- 保留的目录:
- scripts: 是
- references: 否
- prompts: 否
- 外部依赖:bun
- 风险等级:低
- 已检测到的环境变量:
HOME - 配置兼容性:保留原的行为,必要时在运行时包装器中添加OpenClaw兼容路径。
.baoyu-skills/<skill>/EXTEND.md
OpenClaw Preflight Checks
OpenClaw预检查
- Confirm is available when script examples use
bun.npx -y bun ...
Detected env vars:
HOME- 当脚本示例使用时,确认
npx -y bun ...已可用。bun
已检测到的环境变量:
HOMEOpenClaw Failure Fallback
OpenClaw故障回退方案
- If runtime dependency is missing, stop execution and return exact install/setup command.
- 如果缺少运行时依赖,停止执行并返回准确的安装/设置命令。