← 返回 Skills 市场
aga-j

ImageCompress

作者 aga-j · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
93
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install image-tiny-compress
功能描述
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...
使用说明 (SKILL.md)

\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.com or tinify.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
安全使用建议
This skill is coherent with its description, but note two operational risks before installing: 1) Images are uploaded to TinyPNG/Tinify servers — do not upload sensitive or private images. The script also intentionally spoofs User-Agent and X-Forwarded-For to reduce rate-limiting; while effective for reliability, that behavior can violate the service's terms or be considered abusive. If you expect heavy/bulk usage, prefer registering for TinyPNG's official API (uses an API key) to avoid misuse and potential blocking. Finally, verify you trust the skill source before executing scripts that will upload your files to the network.
能力评估
Purpose & Capability
Name/description (compress images via TinyPNG web endpoint) match the code and declared requirements: python3 and the requests package. No unrelated credentials, binaries, or config paths are requested.
Instruction Scope
SKILL.md and the script confine actions to reading image files and performing POST/GET requests to tinypng.com or tinify.cn. The script explicitly spoofs User-Agent and X-Forwarded-For headers and uses randomized tokens to avoid rate-limiting — this is within the stated goal (avoid rate limiting) but is also an evasion technique that may violate Tinypng's terms of service or be viewed as abusive. The README warns about using the web frontend rather than the official API.
Install Mechanism
Install spec only pulls the Python 'requests' package. No downloads from unknown URLs or archive extraction. The listed installer kind is 'uv' (registry metadata) — this appears to map to installing the requests package and is proportionate for a Python script.
Credentials
No environment variables, secrets, or credentials are requested. The script requires network access to tinypng/tinify domains only. This is proportional to the skill's purpose.
Persistence & Privilege
Skill is user-invocable, not always-enabled, and does not request elevated or persistent system privileges. It does not modify other skills or system-wide configs.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install image-tiny-compress
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /image-tiny-compress 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
slug update
元数据
Slug image-tiny-compress
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

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。

💬 留言讨论