baoyu-compress-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image Compressor

图片压缩工具

Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp).
使用当前可用的最优工具(sips → cwebp → ImageMagick → Sharp)压缩图片。

Script Directory

脚本目录

Scripts in
scripts/
subdirectory. Replace
${SKILL_DIR}
with this SKILL.md's directory path.
ScriptPurpose
scripts/main.ts
Image compression CLI
脚本位于
scripts/
子目录中。将
${SKILL_DIR}
替换为当前SKILL.md所在的目录路径。
脚本用途
scripts/main.ts
图片压缩CLI工具

Preferences (EXTEND.md)

偏好设置(EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):
bash
undefined
使用Bash检查EXTEND.md是否存在(优先级顺序):
bash
undefined

Check 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 preference
test -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

选项

OptionShortDescriptionDefault
<input>
File or directoryRequired
--output
-o
Output pathSame path, new ext
--format
-f
webp, png, jpegwebp
--quality
-q
Quality 0-10080
--keep
-k
Keep originalfalse
--recursive
-r
Process subdirsfalse
--json
JSON outputfalse
选项简写描述默认值
<input>
文件或目录必填
--output
-o
输出路径原路径,新扩展名
--format
-f
webp, png, jpegwebp
--quality
-q
质量(0-100)80
--keep
-k
保留原文件false
--recursive
-r
处理子目录false
--json
JSON格式输出false

Examples

示例

bash
undefined
bash
undefined

Single 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)
undefined
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json

**输出示例**:
image.png → image.webp (245KB → 89KB, 压缩比64%)
undefined

Extension 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
    .baoyu-skills/<skill>/EXTEND.md
    behavior and add OpenClaw-compatible path in runtime wrappers when needed.
  • 迁移模式:优先使用OpenClaw原生方式
  • 保留的目录:
    • scripts: 是
    • references: 否
    • prompts: 否
  • 外部依赖:bun
  • 风险等级:低
  • 已检测到的环境变量:
    HOME
  • 配置兼容性:保留原
    .baoyu-skills/<skill>/EXTEND.md
    的行为,必要时在运行时包装器中添加OpenClaw兼容路径。

OpenClaw Preflight Checks

OpenClaw预检查

  • Confirm
    bun
    is available when script examples use
    npx -y bun ...
    .
Detected env vars:
HOME
  • 当脚本示例使用
    npx -y bun ...
    时,确认
    bun
    已可用。
已检测到的环境变量:
HOME

OpenClaw Failure Fallback

OpenClaw故障回退方案

  • If runtime dependency is missing, stop execution and return exact install/setup command.
  • 如果缺少运行时依赖,停止执行并返回准确的安装/设置命令。