image-compression

👤 user_34ee2070 📦 v1.0.0 ⭐ 4.4 ⬇️ 461 下载
🎨 设计多媒体 免费

📖 技能介绍


name: image-compression description: | Compress PNG images to reduce file size while maintaining visual quality. Use this skill whenever the user asks to compress images, reduce image file size, optimize PNG files, make images smaller, batch compress PNGs, or any request involving shrinking image file sizes. Trigger also when the user mentions images being "too large", "need to save space", or wants to "optimize" images for web/storage. compatibility: - Python 3 - Pillow (PIL)


Image Compression Skill

Compress PNG images using Python/Pillow. Two modes:

  • Lossless — no quality loss, but moderate size reduction (typically 1-30%)
  • Lossy — reduces color count to 256, significant size reduction (typically 50-80%) with minimal visual difference

Supports both single file and batch (folder) processing.

When the user provides input

They may say things like: - "Compress this image" — ask if they want lossless or lossy - "Compress all PNGs in this folder" — batch process a directory - "Make this image smaller" — default to lossy for significant savings - Point to a file or folder path

If the user doesn't specify mode, ask: "lossless (keep quality) or lossy (much smaller)?"

Workflow

  1. Understand the scope: Single file or batch? Lossless or lossy?

  2. Lossless:

  3. Save with optimize=True and compress_level=9
  4. Best for screenshots with text/UI elements where sharpness matters

  5. Lossy:

  6. Quantize to 256 colors using Image.Quantize.MEDIANCUT
  7. Save with optimize=True
  8. Best for photos, gradients, or any image where small file size is priority

  9. Report results: original size → compressed size → savings percentage

Script

A helper script compress_png.py handles both modes:

# Lossless (default)
python scripts/compress_png.py <path> [--output OUTPUT] [--overwrite]

# Lossy
python scripts/compress_png.py <path> [--output OUTPUT] [--overwrite] --lossy
  • <path>: Path to a PNG file or a directory
  • --output: Output path (single file) or output directory (batch)
  • --overwrite: Overwrite original files
  • --lossy: Use lossy compression (256 colors)

Example interaction

User: "compress this image C:\Users\me\image.png it's too big" You: "Lossless or lossy?" User: "lossy" You: Compress, report:

Original: 1.2 MB → Lossy: 440 KB (saved 63%)

🤖 AI 评测

这个 Skill 质量不错,操作简单,支持多种压缩方式,能满足单张和批量图片的压缩需求。文档清晰易懂,代码实现稳定可靠。主要不足是测试覆盖不够全面,可能存在一些边界情况没有考虑到,但日常使用应该足够。总体推荐使用。

📊 多维度评分

适应性4.6
规范性4.1
有效性4.6
可靠性4.2
可信度4.4

📁 包含文件 (3 个)

📄 SKILL.md 2.3 KB
📄 evals/evals.json 909 B
📄 scripts/compress_png.py 4.6 KB

🔥 大家都在搜

wps 写作 pdf 苹果