Skip to content
Back to skills

Compression Runtime

ASecurity

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.

  • 16 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
ai-agentsbashbackend

Works with

  • cli

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add onfire7777/universal-ai-skills-library --skill compression-runtime --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Compression Runtime?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Compression Runtime
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/onfire7777-compression-runtime/badge)](https://www.skillsdirectory.com/skills/onfire7777-compression-runtime)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: compression-runtime
description: 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.
metadata: { "pattern": ["tool-wrapper"], "openclaw": { "emoji": "πŸ“¦", "requires": { "anyBins": ["sips", "cwebp", "magick"] } } }
---

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

- `scripts/main.ts`

## Use Cases

- files are too large to share easily
- output needs to be converted to `webp`
- a lighter preview image is needed
- images should be optimized before social upload

## Example Prompts

- `Compress my cover image to webp for social upload`
- `Optimize all images in the output directory to reduce file size`
- `Convert this PNG to a lighter webp format at quality 80`

**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

```bash
${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:

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

Single image to JPEG:

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

Recursive directory compression:

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

JSON output:

```bash
${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:

- keep the original image untouched
- write the compressed result under a new name
- store results in the same directory or in a `compressed/` subdirectory

Example:

```text
cover-image/topic-slug/
β”œβ”€β”€ cover.png
└── compressed/
    └── cover.webp
```

## Re-run Behavior

- Re-compressing the same input produces a new output file (or overwrites an existing one at the same path).
- The original input is never modified unless `--keep` is used and the output extension matches the input.
- `--recursive` re-processes all matching files in the directory, including previously compressed ones.
- To avoid double-compression, point `--output` to a separate `compressed/` subdirectory.

## Definition of Done

- The compressed output file exists and is smaller than the input.
- The original file is preserved (not overwritten) unless `--keep` is used with matching extensions.
- Output format matches the requested `--format`.
- `--json` mode produces a valid JSON summary with input size, output size, and compression ratio.

## Current Behavior

- prefers `cwebp` -> `magick` / `convert` -> `sips`
- supports single files and directories
- supports recursive scanning
- supports JSON summaries
- does not delete the original just because the format changes; use `--keep` when the output extension matches the input
- `webp` output requires `cwebp` or ImageMagick; if only `sips` is available, prefer `png` or `jpeg`

Files in this skill

  • AGENTS.md184 B
  • SKILL.md3.9 KB
  • package.json246 B
  • scripts/main.ts12.2 KB
  • scripts/package.json196 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…