baoyu-compress-image

Compress images to WebP, PNG, or JPEG using sips, cwebp, ImageMagick, or Sharp.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/chhpt/skills --skill baoyu-compress-image-chhpt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: baoyu-compress-image
Source: https://github.com/chhpt/skills/tree/main/skills/baoyu-compress-image
Command: npx skills add https://github.com/chhpt/skills --skill baoyu-compress-image-chhpt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sharp, and includes scripts (resource) components.

What problem does it solve? Large image files slow down websites and consume storage, and manually converting or compressing them one by one is tedious. This Skill compresses single images or entire directories into WebP, PNG, or JPEG with automatic selection of the best available compression tool on your system. ## Core Features & Use Cases - Automatic Tool Selection: Detects and uses the best available compressor in priority order (sips on macOS, cwebp, ImageMagick, or Sharp as fallback). - Batch & Recursive Processing: Compress a single file or recursively process entire directories of PNG, JPG, WebP, GIF, and TIFF images. - Flexible Output Control: Configure format, quality (0-100), output path, keep-original behavior, and JSON output for scripting. - Use Case: Before deploying a website, run the Skill on your ./images/ folder recursively at quality 75 to convert all assets to WebP and see the total size reduction report. ## Quick Start Ask the AI to compress the image 'hero.png' to WebP format, or recursively compress all images in a folder at quality 75.

Frequently Asked Questions about baoyu-compress-image

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compress an image to WebP from the command line?

Run the main.ts script with Bun, passing the image path as input. By default it outputs WebP at quality 80, automatically choosing cwebp, ImageMagick, or Sharp depending on which tools are installed.

How to batch compress all images in a folder recursively?

Pass a directory path as input with the -r flag to process subdirectories. The script finds all PNG, JPG, JPEG, WebP, GIF, and TIFF files and reports total size reduction after processing.

What image compression tools does it support: cwebp vs ImageMagick vs Sharp?

For WebP output it prefers cwebp, then ImageMagick, then Sharp as a pure-JavaScript fallback. For PNG and JPEG it uses sips on macOS, otherwise ImageMagick or Sharp. Detection happens automatically at runtime.

Does compressing an image delete the original file?

By default the original is renamed with an _original suffix rather than deleted. Use the -k or --keep flag to keep the original untouched, in which case the compressed file gets a -compressed suffix if the format is unchanged.

Why does image compression fail with a tool not found error?

The script falls back to the Sharp npm package when no system tools like cwebp or ImageMagick exist, so Sharp must be installable in the environment. Check that Bun can resolve the sharp module if other compressors are unavailable.