← 返回
未分类

skillname01

This skill should be used whenever the user wants to compress, reduce, or optimize image files. Trigger when users say things like "compress this image", "reduce image size", "batch compress images", "convert image format", "resize and compress", "压缩图片", "批量压缩图片", "图片瘦身", "把图片压缩到XX KB以内", or ask to reduce file size of JPG/PNG/WebP/GIF files.
user_a5db3b4e
未分类 community v1.0.0 1 版本 99137.9 Key: 无需
★ 0
Stars
📥 115
下载
💾 1
安装
1
版本
#latest

概述

Image Compress Skill

Compress and optimize image files with full control over quality, target file size, output format, and dimensions. Supports single images and batch directory processing.

Supported Formats

JPEG, PNG, WebP, GIF, BMP, TIFF

Script

The core script is located at: scripts/compress_image.py

Requires Pillow. If not installed, run: pip install Pillow

Usage

python scripts/compress_image.py <input> [options]

Key Options

OptionDescriptionDefault
------------------------------
-o, --output Output file or directory_compressed. next to input
-q, --quality <1-95>JPEG/WebP quality85
-s, --max-size Target max file size in KB (auto-adjusts quality)None
-f, --format Output format: jpeg, png, webp, gifKeep original
-w, --width Resize width (preserves aspect ratio)No resize
-H, --height Resize height (preserves aspect ratio)No resize
--batchBatch process all images in a directoryOff
--no-overwriteSkip files that already exist at output pathOff
-v, --verboseShow per-file size and quality infoOff

Common Workflows

Compress a single image with quality control

python scripts/compress_image.py photo.jpg -q 80 -v

Compress to a specific file size limit

python scripts/compress_image.py photo.jpg -s 200 -v
# → Automatically finds the highest quality that fits within 200 KB

Convert PNG to WebP and compress

python scripts/compress_image.py image.png -f webp -q 85 -o output/

Resize and compress

python scripts/compress_image.py photo.jpg -w 1920 -q 85 -o resized/

Batch compress all images in a directory

python scripts/compress_image.py ./images/ --batch -q 80 -v
# → Outputs to ./images/compressed/

Batch compress to target size and convert to WebP

python scripts/compress_image.py ./images/ --batch -f webp -s 300 -o ./webp_output/ -v

Notes

  • When the user asks to compress an image but does not specify quality or target size, default to -q 85 -v.
  • When the user specifies a target size (e.g., "compress to under 500KB"), use -s which auto-finds the best quality.
  • PNG compression is lossless; -q controls compress level, not visual quality.
  • RGBA/transparent images saved as JPEG will be composited onto a white background automatically.
  • Always use -v to show the user before/after file sizes and compression ratio.
  • If Pillow is not installed, run pip install Pillow before executing the script.

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-02 11:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,217 📥 266,685
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 671 📥 324,344
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,006