/install image-tiny-compress
\r \r
TinyCompress — Smart Image Compression\r
\r \x3Cdescription>\r Use when: compressing images, optimizing image file size, reducing image size, tinypng, tinify, compress image, compress png, compress jpeg, compress webp, image optimization, shrink image, 压缩图片, 图片压缩, 图片优化, 图片瘦身, 减小图片体积\r NOT for: image resizing/cropping, format conversion, image editing, video compression\r \x3C/description>\r \r
Overview\r
\r TinyCompress uses TinyPNG/Tinify's free web API to perform high-quality lossy compression on PNG, JPEG, and WebP images. No API key, no login, no payment required.\r \r Key Features:\r
- Free — no API key or registration needed\r
- Supports PNG, JPEG, WebP formats\r
- Max 5MB per image, up to 20 images per batch\r
- Supports global server (tinypng.com) and China server (tinify.cn)\r
- Auto retry with exponential backoff on failure\r
- Rate-limit friendly with built-in request delays\r
- Typical compression: 50%~80% size reduction with near-zero visual quality loss\r \r
Prerequisites\r
\r
- Python 3.6+ must be installed\r
- requests library:
pip install requests\r - Network access to
tinypng.comortinify.cn\r \r
Usage\r
\r
1. Single Image Compression\r
\r When a user uploads or specifies one image:\r \r
python "{SKILL_DIR}/scripts/tiny_compress.py" compress "\x3Cimage_path>"\r
```\r
\r
Use China server for faster speed in China:\r
```bash\r
python "{SKILL_DIR}/scripts/tiny_compress.py" compress "\x3Cimage_path>" --server cn\r
```\r
\r
Output: generates `\x3Cfilename>_compressed.\x3Cext>` in the same directory.\r
\r
### 2. Batch Compression\r
\r
When a user provides multiple images:\r
\r
```bash\r
python "{SKILL_DIR}/scripts/tiny_compress.py" compress "\x3Cfile1>" "\x3Cfile2>" ... --output-dir "\x3Coutput_dir>"\r
```\r
\r
### 3. Directory Compression\r
\r
When a user specifies a directory:\r
\r
```bash\r
python "{SKILL_DIR}/scripts/tiny_compress.py" compress-dir "\x3Cdir_path>" --output-dir "\x3Coutput_dir>"\r
```\r
\r
Add `--recursive` to include subdirectories.\r
\r
### 4. Overwrite Mode\r
\r
When user explicitly wants to replace original files:\r
\r
```bash\r
python "{SKILL_DIR}/scripts/tiny_compress.py" compress "\x3Cfile>" --overwrite\r
```\r
\r
⚠️ **Warning:** Overwriting is irreversible. Always warn the user and suggest backup first.\r
\r
## Script Reference\r
\r
### scripts/tiny_compress.py\r
\r
| Subcommand | Description |\r
|------------|-------------|\r
| `compress \x3Cfiles...>` | Compress one or more image files |\r
| `compress-dir \x3Cdir>` | Compress all images in a directory |\r
\r
| Parameter | Description | Default |\r
|-----------|-------------|---------|\r
| `--output-dir \x3Cdir>` | Output directory | Same dir with `_compressed` suffix |\r
| `--server cn\|global` | Server selection | `global` |\r
| `--overwrite` | Overwrite original files | `false` |\r
| `--recursive` | Recurse into subdirectories (compress-dir only) | `false` |\r
\r
**How it works:**\r
- Upload endpoint: `POST https://tinypng.com/backend/opt/shrink` (or `tinify.cn/backend/opt/shrink`)\r
- Uploads raw image binary → server returns compression info + download URL → downloads compressed image\r
- Uses randomized User-Agent and X-Forwarded-For headers\r
- Serial processing with 1.5s delay between requests to avoid rate limiting\r
- Auto retry up to 3 times with exponential backoff\r
\r
**Output format (per image):**\r
```json\r
{\r
"success": true,\r
"file": "original_path",\r
"output": "output_path",\r
"original_size": 1234567,\r
"compressed_size": 345678,\r
"saved_bytes": 888889,\r
"saved_percent": 72.0\r
}\r
```\r
\r
## Examples\r
\r
```\r
User: "Compress this image" (uploads photo.png)\r
Agent: runs compress on photo.png → returns photo_compressed.png with stats\r
\r
User: "Compress all images in ./screenshots"\r
Agent: runs compress-dir ./screenshots → returns compressed versions\r
\r
User: "Use China server, compress these 3 photos"\r
Agent: runs compress with --server cn on all 3 files\r
```\r
\r
## Limitations\r
\r
- Max 5MB per image (TinyPNG web limit)\r
- Max 20 images per batch\r
- This uses TinyPNG's web frontend endpoint (not official API), may change without notice\r
- High-frequency requests may be temporarily rate-limited\r
- Does not support AVIF, GIF, BMP formats\r
- Uploaded images are auto-deleted from TinyPNG servers after 48 hours\r
\r
## Important Notes\r
\r
- **Privacy:** Images are uploaded to TinyPNG servers for processing. Do NOT upload images containing sensitive/personal information.\r
- **Fair Use:** This method simulates web browser access. Use responsibly, avoid excessive automated calls.\r
- **Network:** Requires access to tinypng.com or tinify.cn.\r
- **Alternative:** For heavy batch processing, consider registering for TinyPNG's official API key (500 free compressions/month).\r
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install image-tiny-compress - 安装完成后,直接呼叫该 Skill 的名称或使用
/image-tiny-compress触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
ImageCompress 是什么?
Compress PNG, JPEG, WebP images using TinyPNG/Tinify free web API. No API key required, no login needed. Supports single/batch/directory compression with aut... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 93 次。
如何安装 ImageCompress?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install image-tiny-compress」即可一键安装,无需额外配置。
ImageCompress 是免费的吗?
是的,ImageCompress 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
ImageCompress 支持哪些平台?
ImageCompress 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 ImageCompress?
由 aga-j(@aga-j)开发并维护,当前版本 v1.0.1。