Compression runtime

From onfire7777/universal-ai-skills-library · View interactive version

Compression runtime is an AI agent skill from the GitHub repository onfire7777/universal-ai-skills-library. Compress or convert generated images for delivery, preview, and social upload. Use when the user asks to compress an image, optimize image size, convert to webp, or reduce file size after generation.

How to use this skill

Skill file

Bundled Compression Runtime

Compress or convert generated images for delivery, preview, and social upload. Optimize image size, convert to webp, or reduce file size after generation.

This skill uses the best available local toolchain and stays self-contained.

Script:

Use Cases

Example Prompts

Important: at least one of cwebp, magick, or sips must be available locally.

Backend Preference

Preferred order:

  1. cwebp for WebP output
  2. magick or convert for conversion and flexible processing
  3. sips as a macOS-native fallback

CLI

${BUN_X} {baseDir}/scripts/main.ts <input> [options]

Options

| Option | Description |

| --- | --- |

| <input> | input file or directory |

| --output, -o | output file or directory |

| --format, -f | webp, png, or jpeg (default: webp) |

| --quality, -q | quality 0-100 (default: 80) |

| --keep, -k | keep the original when the output extension matches the input |

| --recursive, -r | process directories recursively |

| --json | return JSON output |

Common Examples

Single image to WebP:

${BUN_X} {baseDir}/scripts/main.ts input.png -f webp -q 80

Single image to JPEG:

${BUN_X} {baseDir}/scripts/main.ts input.png -f jpeg -q 82

Recursive directory compression:

${BUN_X} {baseDir}/scripts/main.ts ./images -r -f webp

JSON output:

${BUN_X} {baseDir}/scripts/main.ts input.png --json

Workflow

  1. Identify the input: a single image file or a directory of images.
  2. Choose the target format (webp, png, or jpeg) and quality level.
  3. Run the CLI with the chosen options.
  4. Verify the output exists and is smaller than the input.
  5. If processing a directory, use --recursive to handle nested folders.

Output Convention

Recommended behavior:

Example:

cover-image/topic-slug/
├── cover.png
└── compressed/
    └── cover.webp

Re-run Behavior

Definition of Done

Current Behavior

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.