Back to Skills

baoyu-compress-image

Compresses images to WebP (default) or PNG with automatic tool selection. Use when user asks to "compress image", "optimize image", "convert to webp", or reduce image file size.

14,162stars1,632forksUpdated 4/12/2026

Security Assessment

Safe(100/100)
Security Score100/100

About baoyu-compress-image

The baoyu-compress-image skill provides a streamlined solution for compressing and optimizing images, converting them primarily to WebP format or optionally to PNG and JPEG. It automatically selects the most efficient available tool on the system, including sips, cwebp, ImageMagick, or Sharp, to achieve significant file size reductions while maintaining quality. This skill addresses the common challenge of managing large image files, improving website load times, and reducing storage usage without requiring manual intervention or extensive technical knowledge from the user.

Key features of baoyu-compress-image include automatic tool selection based on availability, flexible input handling for single files or entire directories, and customizable output options such as format, quality, and recursive processing. Users can also choose to retain the original file, generate JSON output for automated workflows, and leverage custom configurations through EXTEND.md for default format, quality, and preservation preferences. The skill provides a command-line interface using bun or npx, ensuring compatibility across macOS, Linux, WSL, Git Bash, and Windows PowerShell environments.

This skill is particularly useful for web developers, content creators, and system administrators who need to optimize large numbers of images efficiently. Common use cases include reducing image file sizes for websites and apps to improve performance, converting legacy images to modern formats for better compression, and maintaining a consistent image quality across projects. Its straightforward CLI interface and support for both single images and directories make it accessible for both individual and automated batch workflows.

FAQ

How do I compress a single image to WebP format?

Use the command `${BUN_X} {baseDir}/scripts/main.ts <input>` where `<input>` is the path to your image. By default, the output will be WebP and replace the original file.

Can I keep the original image format while compressing?

Yes, use the `--keep` option along with `-f` to specify the desired format, for example `-f png --keep`.

Does this skill support processing entire directories?

Yes, use the `--recursive` or `-r` option to process all images in a directory and its subdirectories.

Which tools does baoyu-compress-image use for compression?

It automatically selects the best available tool from sips, cwebp, ImageMagick, or Sharp, depending on what is installed on your system.

What are the system requirements?

Requires either `bun` or `npx` installed to run the CLI scripts. It supports macOS, Linux, WSL, Git Bash, and Windows PowerShell environments.

All Files

2 files
scripts/main.ts9.8 KB
View
SKILL.md3.8 KB
View

Install baoyu-compress-image

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill