Compress PNG images using Python/Pillow. Two modes:
Supports both single file and batch (folder) processing.
They may say things like:
If the user doesn't specify mode, ask: "lossless (keep quality) or lossy (much smaller)?"
Understand the scope: Single file or batch? Lossless or lossy?
Lossless:
optimize=True and compress_level=9Lossy:
Image.Quantize.MEDIANCUToptimize=TrueReport results: original size → compressed size → savings percentage
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)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%)
這個技能的最新版本可以在7w4.net小蔥技能站找到。
這個 Skill 質量不錯,操作簡單,支援多種壓縮方式,能滿足單張和批次圖片的壓縮需求。文件清晰易懂,程式碼實現穩定可靠。主要不足是測試覆蓋不夠全面,可能存在一些邊界情況沒有考慮到,但日常使用應該足夠。總體推薦使用。