by jimliu
大型图像文件会降低网站速度并浪费存储空间。此技能可将图像压缩为WebP、PNG或JPEG格式,支持可调整的质量设置,适用于单个文件和整个目录。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 baoyu-compress-image 技能" 开始使用
=== baoyu-compress-image 技能 === 作者: jimliu 描述: 大型图像文件会降低网站速度并浪费存储空间。此技能可将图像压缩为WebP、PNG或JPEG格式,支持可调整的质量设置,适用于单个文件和整个目录。 使用方法: 1. 调用技能: "使用 baoyu-compress-image 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 baoyu-compress-image 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
productivity
safe
Cross-platform image compression with WebP default output, PNG-to-PNG support, preferring system tools with Sharp fallback.
Important: All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions:
SKILL_DIR${SKILL_DIR}/scripts/<script-name>.ts${SKILL_DIR} in this document with the actual pathScript Reference:
| Script | Purpose |
|---|---|
scripts/main.ts | CLI entry point for image compression |
# Compress to WebP (default)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
# Keep original format (PNG → PNG)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --format png
# Custom quality
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -q 75
# Process directory
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r
# Basic (converts to WebP, replaces original)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
# Custom output path
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -o compressed.webp
# Keep original file
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --keep
# Custom quality (0-100, default: 80)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -q 75
# Keep original format
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png
# Process all images in directory
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/
# Recursive processing
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r
# With custom quality
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75
# Plain text (default)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
# JSON output
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json
| Option | Short | Description | Default |
|---|---|---|---|
<input> | Input file or directory | Required | |
--output <path> | -o | Output path | Same path, new extension |
--format <fmt> | -f | webp, png, jpeg | webp |
--quality <n> | -q | Quality 0-100 | 80 |
--keep | -k | Keep original file | false |
--recursive | -r | Process directories recursively | false |
--json | JSON output | false | |
--help | -h | Show help |
Priority order (auto-detected):
convert command)The skill automatically selects the best available compressor.
image.png → image.webp (245KB → 89KB, 64% reduction)
{
"input": "image.png",
"output": "image.webp",
"inputSize": 250880,
"outputSize": 91136,
"ratio": 0.36,
"compressor": "sips"
}
{
"files": [...],
"summary": {
"totalFiles": 10,
"totalInputSize": 2508800,
"totalOutputSize": 911360,
"ratio": 0.36,
"compressor": "sips"
}
}
npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png
# photo.png → photo.webp (1.2MB → 340KB, 72% reduction)
npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png -q 60
# photo.png → photo.webp (1.2MB → 280KB, 77% reduction)
npx -y bun ${SKILL_DIR}/scripts/main.ts screenshot.png -f png --keep
# screenshot.png → screenshot-compressed.png (500KB → 380KB, 24% reduction)
npx -y bun ${SKILL_DIR}/scripts/main.ts ./screenshots/ -r
# Processed 15 files: 12.5MB → 4.2MB (66% reduction)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json | jq '.ratio'
Custom configurations via EXTEND.md.
Check paths (priority order):
.baoyu-skills/baoyu-compress-image/EXTEND.md (project)~/.baoyu-skills/baoyu-compress-image/EXTEND.md (user)If found, load before workflow. Extension content overrides defaults.
View Count
0
Download Count
0
Favorite Count
0
Quality Score
72