鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

baoyu-compress-image

提供跨平台图像压缩能力,支持默认转为 WebP 格式或保持原格式(如 PNG 到 PNG),自动选用系统级工具(macOS sips、cwebp、ImageMagick)或 Node.js 的 Sharp 库,兼顾效率与兼容性。

内容与媒体
访问 GitHub
文档Skills.MD
name
baoyu-compress-image
description
Cross-platform image compression skill. Converts images to WebP by default with PNG-to-PNG support. Uses system tools (sips, cwebp, ImageMagick) with Sharp fallback.

Image Compressor

Cross-platform image compression with WebP default output, PNG-to-PNG support, preferring system tools with Sharp fallback.

Script Directory

Important: All scripts are located in the scripts/ subdirectory of this skill.

Agent Execution Instructions:

  1. Determine this SKILL.md file's directory path as SKILL_DIR
  2. Script path = ${SKILL_DIR}/scripts/<script-name>.ts
  3. Replace all ${SKILL_DIR} in this document with the actual path

Script Reference:

ScriptPurpose
scripts/main.tsCLI entry point for image compression

Quick Start

▼
bash
复制代码
# 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

Commands

Single File Compression

▼
bash
复制代码
# 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

Directory Processing

▼
bash
复制代码
# 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

Output Formats

▼
bash
复制代码
# 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

Options

OptionShortDescriptionDefault
<input>Input file or directoryRequired
--output <path>-oOutput pathSame path, new extension
--format <fmt>-fwebp, png, jpegwebp
--quality <n>-qQuality 0-10080
--keep-kKeep original filefalse
--recursive-rProcess directories recursivelyfalse
--jsonJSON outputfalse
--help-hShow help

Compressor Selection

Priority order (auto-detected):

  1. sips (macOS built-in, WebP support since macOS 11)
  2. cwebp (Google's official WebP tool)
  3. ImageMagick (convert command)
  4. Sharp (npm package, auto-installed by Bun)

The skill automatically selects the best available compressor.

Output Format

Text Mode (default)

▼
text
复制代码
image.png → image.webp (245KB → 89KB, 64% reduction)

JSON Mode

▼
json
复制代码
{ "input": "image.png", "output": "image.webp", "inputSize": 250880, "outputSize": 91136, "ratio": 0.36, "compressor": "sips" }

Directory JSON Mode

▼
json
复制代码
{ "files": [...], "summary": { "totalFiles": 10, "totalInputSize": 2508800, "totalOutputSize": 911360, "ratio": 0.36, "compressor": "sips" } }

Examples

Compress single image

▼
bash
复制代码
npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png # photo.png → photo.webp (1.2MB → 340KB, 72% reduction)

Compress with custom quality

▼
bash
复制代码
npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png -q 60 # photo.png → photo.webp (1.2MB → 280KB, 77% reduction)

Keep original format

▼
bash
复制代码
npx -y bun ${SKILL_DIR}/scripts/main.ts screenshot.png -f png --keep # screenshot.png → screenshot-compressed.png (500KB → 380KB, 24% reduction)

Process entire directory

▼
bash
复制代码
npx -y bun ${SKILL_DIR}/scripts/main.ts ./screenshots/ -r # Processed 15 files: 12.5MB → 4.2MB (66% reduction)

Get JSON for scripting

▼
bash
复制代码
npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json | jq '.ratio'

Extension Support

Custom configurations via EXTEND.md.

Check paths (priority order):

  1. .baoyu-skills/baoyu-compress-image/EXTEND.md (project)
  2. ~/.baoyu-skills/baoyu-compress-image/EXTEND.md (user)

If found, load before workflow. Extension content overrides defaults.

内容与媒体

快捷安装

复制到终端去安装 Skill

npxskillsaddJimLiu/baoyu-skills--skill"baoyu-compress-image"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
docx
支持专业级 Word 文档的全生命周期处理,包括从零创建结构化文档、精准编辑内容、管理修订痕迹与批注、提取纯文本或原始 XML 数据、转换为 PDF 或图像用于视觉分析,适用于法律、学术及企业场景下的高保真文档协作与自动化处理。
mermaid-sequence-diagram-creator
自动生成和优化序列图内容,支持可视化文档的快速构建与标准化输出,适用于图表设计、技术文档及演示材料的高效创作场景。
product-copy-assistant
为产品界面、文档和系统消息生成清晰简洁的用户文案,覆盖按钮标签、错误提示、工具提示、引导流程、空状态、确认对话框等场景,兼顾可访问性与不同角色(如开发者或终端用户)的语言习惯和实际需求。
office
生成和操作 Office 文档与 PDF,支持在 Node.js、浏览器及边缘运行时环境中创建 DOCX、XLSX、PPTX 和 PDF 文件,适用于报表生成、发票导出、数据可视化及文档自动化场景。
market-research-reports
生成面向战略决策的深度市场研究报告,涵盖行业分析、竞争格局、客户细分、技术趋势及风险评估,集成波特五力、PESTLE、SWOT、TAM/SAM/SOM 和 BCG 矩阵等多维框架,辅以专业级 LaTeX 排版与科学图表生成,输出 50 页以上 PDF 报告。