canghe-compress-image by freestylefly/canghe-skills
npx skills add https://github.com/freestylefly/canghe-skills --skill canghe-compress-image使用最佳可用工具压缩图片(sips → cwebp → ImageMagick → Sharp)。
脚本位于 scripts/ 子目录中。请将 ${SKILL_DIR} 替换为此 SKILL.md 文件所在的目录路径。
| 脚本 | 用途 |
|---|---|
scripts/main.ts | 图片压缩命令行工具 |
使用 Bash 检查 EXTEND.md 文件是否存在(优先级顺序):
# 首先检查项目级别
test -f .canghe-skills/canghe-compress-image/EXTEND.md && echo "project"
# 然后检查用户级别(跨平台:$HOME 在 macOS/Linux/WSL 上均适用)
test -f "$HOME/.canghe-skills/canghe-compress-image/EXTEND.md" && echo "user"
┌────────────────────────────────────────────────────────┬───────────────────┐ │ 路径 │ 位置 │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ .canghe-skills/canghe-compress-image/EXTEND.md │ 项目目录 │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.canghe-skills/canghe-compress-image/EXTEND.md │ 用户主目录 │ └────────────────────────────────────────────────────────┴───────────────────┘
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ 结果 │ 操作 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 找到 │ 读取、解析、应用设置 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 未找到 │ 使用默认值 │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md 支持 : 默认格式 | 默认质量 | 保留原文件偏好
npx -y bun ${SKILL_DIR}/scripts/main.ts <input> [options]
| 选项 | 简写 | 描述 | 默认值 |
|---|---|---|---|
<input> | 文件或目录 | 必需 | |
--output | -o | 输出路径 | 相同路径,新扩展名 |
--format | -f | webp, png, jpeg | webp |
--quality | -q | 质量 0-100 | 80 |
--keep | -k | 保留原文件 | false |
--recursive | -r | 处理子目录 | false |
--json | JSON 输出 | false |
# 单个文件 → WebP(替换原文件)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
# 保持 PNG 格式
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png --keep
# 目录递归处理
npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75
# JSON 输出
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json
输出 :
image.png → image.webp (245KB → 89KB, 64% reduction)
通过 EXTEND.md 进行自定义配置。有关路径和支持的选项,请参阅 偏好设置 部分。
每周安装量
99
代码仓库
GitHub 星标数
182
首次出现
2026年2月24日
安全审计
安装于
github-copilot98
gemini-cli98
codex98
kimi-cli98
cursor98
opencode98
Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp).
Scripts in scripts/ subdirectory. Replace ${SKILL_DIR} with this SKILL.md's directory path.
| Script | Purpose |
|---|---|
scripts/main.ts | Image compression CLI |
Use Bash to check EXTEND.md existence (priority order):
# Check project-level first
test -f .canghe-skills/canghe-compress-image/EXTEND.md && echo "project"
# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.canghe-skills/canghe-compress-image/EXTEND.md" && echo "user"
┌────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ .canghe-skills/canghe-compress-image/EXTEND.md │ Project directory │ ├────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.canghe-skills/canghe-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
npx -y bun ${SKILL_DIR}/scripts/main.ts <input> [options]
| Option | Short | Description | Default |
|---|---|---|---|
<input> | File or directory | Required | |
--output | -o | Output path | Same path, new ext |
--format | -f | webp, png, jpeg | webp |
--quality |
# Single file → WebP (replaces original)
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png
# Keep PNG format
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
# JSON output
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json
Output :
image.png → image.webp (245KB → 89KB, 64% reduction)
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
Weekly Installs
99
Repository
GitHub Stars
182
First Seen
Feb 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot98
gemini-cli98
codex98
kimi-cli98
cursor98
opencode98
Lark Contact CLI 工具:高效搜索与获取飞书用户信息,提升团队协作效率
37,400 周安装
-q |
| Quality 0-100 |
| 80 |
--keep | -k | Keep original | false |
--recursive | -r | Process subdirs | false |
--json | JSON output | false |