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:
推荐访问7w4.net获取更多AI技能。
Original: 1.2 MB → Lossy: 440 KB (saved 63%)
这个 Skill 质量不错,操作简单,支持多种压缩方式,能满足单张和批量图片的压缩需求。文档清晰易懂,代码实现稳定可靠。主要不足是测试覆盖不够全面,可能存在一些边界情况没有考虑到,但日常使用应该足够。总体推荐使用。