Skip to content
baoyu-compress-image logo

Image Compressor

baoyu-compress-image

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.

SKILL.md

Full skill instructions

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

# 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

# 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

# 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

# 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)

image.png → image.webp (245KB → 89KB, 64% reduction)

JSON Mode

{
  "input": "image.png",
  "output": "image.webp",
  "inputSize": 250880,
  "outputSize": 91136,
  "ratio": 0.36,
  "compressor": "sips"
}

Directory JSON Mode

{
  "files": [...],
  "summary": {
    "totalFiles": 10,
    "totalInputSize": 2508800,
    "totalOutputSize": 911360,
    "ratio": 0.36,
    "compressor": "sips"
  }
}

Examples

Compress single image

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

Compress with custom quality

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

Keep original format

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

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

Get JSON for scripting

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.

More Design skills

brandkit logo
Design

brandkit

Premium brand-kit image generation for high-end identity systems, logo concepts, and visual-world presentations.

92.7K 345.8K
View

Premium website design-to-code skill that generates visual references first, then builds faithful frontend implementations.

92.7K 341.7K
View

Premium frontend image direction for landing pages and marketing sites, generating one distinct horizontal image per section.

92.7K 337.8K
View

Premium mobile app screen concepts and flows with clean hierarchy, strong imagery, and distinctive art direction.

92.7K 331.8K
View

Emil Kowalski's philosophy on UI polish, component design, and the invisible details that make software feel good.

43.5K 323.4K
View

Frontend design and iteration for production-grade interfaces, from concept to ship.

76.8K 313.3K
View

Reverse-engineer design tokens from public websites into starter token files for your project.

232 129.9K
View
Animate logo
Design

Animate

Builds an animation from scratch by making the decisions in the order that determines whether it feels right.

43.5K 117.9K
View

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

179.7K 114.2K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

Design AI tools

Maze Guru logo
Images

Maze Guru

Chat-to-edit AI studio for product photos, portraits, branding, and video.

Freemium
View
R
Design

RoomGPT

Generate your dream room in seconds.

Paid
View

Redesign your interior in seconds using AI

Paid
View
Reroom logo
Design

Reroom

Transform rooms with AI-generated designs.

Freemium
View
Jife logo
Design

Jife

Transform Your Space with AI-Powered Japanese Interior Designs by Jife

Paid
View
Visily logo
Design

Visily

AI-powered wireframes for non-designers.

Free
View

Revolutionize Property Viewing with AI-Generated Floor Plans and Virtual Tours

Paid
View
Archsynth logo
Design

Archsynth

Transform sketches into stunning architectural renders with AI.

Paid
View