mcpField
B
baoyu-compress-image

baoyu-compress-image

github.com/tentacle-proCreative & media441 installsUpdated 12w ago
Repository

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

  1. 01Detect an available compression engine
  2. 02Choose JPEG, WebP, or PNG output
  3. 03Set compression quality
  4. 04Process directories recursively
  5. 05Archive or retain original images

Use cases

  1. 01Prepare images for web publishing
  2. 02Convert images to WebP
  3. 03Compress a directory of images
  4. 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-image

After installing, type/baoyu-compress-imagein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

bun.lock
package.json
test-process.ts
scripts/
main.ts

Details

From the project README

baoyu-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 .jpg with 65 quality (perfect for most platform limits < 1MB).
  • Clean Vault: When run in default mode (replace), it doesn't clutter your Assets/ with _original files. Instead, it backs up the original unmodified file to Archive/Original-Images/.
  • Dependency Sandboxing: All runtime is wrapped through bun and 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:

  1. macOS sips (Built-in, Highly Recommended)
    macOS ships with sips natively. No installation required.
    (Under the hood: sips -s format jpeg -s formatOptions 65 <input> --out <output>)

  2. cwebp (Best for webp targets)

    • macOS: brew install webp
    • Ubuntu/Debian: sudo apt install webp
  3. ImageMagick (convert)

    • macOS: brew install imagemagick
    • Linux: sudo apt install imagemagick
  4. sharp (Node.js fallback for Windows / Non-Native Envs)
    Automatically installed when you run the local bun install command. 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
OptionShortDescriptionDefault
<input>Input target (File or directory)Required
--output-oStrict output file pathSame dir as input
--format-fOutput format (jpeg, webp, png)jpeg
--quality-qQuality Level 0-10065
--keep-kKeep original file in-place (don't archive it)false
--recursive-rProcess directories recursivelyfalse

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

Comments

Markdown supported