About baoyu-compress-image
baoyu-compress-image is a command-line skill for compressing images with an available local engine. It is adapted for the Obsidian Creator Vault, with configurable output formats and quality plus an option to archive originals.
Key features
- 01Detect an available compression engine
- 02Choose JPEG, WebP, or PNG output
- 03Set compression quality
- 04Process directories recursively
- 05Archive or retain original images
Use cases
- 01Prepare images for web publishing
- 02Convert images to WebP
- 03Compress a directory of images
- 04Keep originals archived during replacement
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ tentacle-pro/ skills --skill baoyu-compress-imageAfter installing, type/baoyu-compress-imagein Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
bun.lockpackage.jsontest-process.tsscripts/main.tsDetails
From the project READMEbaoyu-compress-image
Auto-compresses images using the best available CLI tool on the system (sips, cwebp, convert, or sharp).
This has been specifically adapted for the Obsidian Creator Vault:
- Fast Web-focused: Defaults to generating
.jpgwith65quality (perfect for most platform limits < 1MB). - Clean Vault: When run in default mode (replace), it doesn't clutter your
Assets/with_originalfiles. Instead, it backs up the original unmodified file toArchive/Original-Images/. - Dependency Sandboxing: All runtime is wrapped through
bunand isolated inside.agents/skills.
Installation & System Requirements
This script automatically detects your OS and uses the fastest and highest quality image engine it can find in this order:
-
macOS
sips(Built-in, Highly Recommended)
macOS ships withsipsnatively. No installation required.
(Under the hood:sips -s format jpeg -s formatOptions 65 <input> --out <output>) -
cwebp(Best for webp targets)- macOS:
brew install webp - Ubuntu/Debian:
sudo apt install webp
- macOS:
-
ImageMagick (
convert)- macOS:
brew install imagemagick - Linux:
sudo apt install imagemagick
- macOS:
-
sharp(Node.js fallback for Windows / Non-Native Envs)
Automatically installed when you run the localbun installcommand. The sharp engine handles compression via libvips without needing external binaries.
First Time Setup (TS Environment):
cd .agents/skills/baoyu-compress-image
bun install
Usage
Run the script using bun from the root of the vault.
bun .agents/skills/baoyu-compress-image/scripts/main.ts <input> [options]
Options
| Option | Short | Description | Default |
|---|---|---|---|
<input> | Input target (File or directory) | Required | |
--output | -o | Strict output file path | Same dir as input |
--format | -f | Output format (jpeg, webp, png) | jpeg |
--quality | -q | Quality Level 0-100 | 65 |
--keep | -k | Keep original file in-place (don't archive it) | false |
--recursive | -r | Process directories recursively | false |
Examples & Workflows
1. Compress a generated AI image for publishing (Default)
bun .agents/skills/baoyu-compress-image/scripts/main.ts Assets/cover-draft.png
Effect: It creates Assets/cover-draft.jpg and safely moves cover-draft.png out of the way into Archive/Original-Images/.
2. Compress an image but keep it as WebP format
bun .agents/skills/baoyu-compress-image/scripts/main.ts Assets/screenshot.png -f webp
3. Test different quality manually and keep the original there
bun .agents/skills/baoyu-compress-image/scripts/main.ts Assets/photo.png -q 80 --keep
4. Batch-compress an entire directory
bun .agents/skills/baoyu-compress-image/scripts/main.ts "00 Inbox/" -r