AI Agent Hub
Back to skills
PNG Image Compression icon

PNG Image Compression

Design & Media Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please follow https://skillhub.cn/install/skillhub.md to install @user_34ee2070/image-compression1.

About this skill

Problem to solve

When PNG screenshots, assets, or batched images are too large, manual compression and repeated setting tweaks are tedious. image-compression focuses on compressing PNG files: provide a file path or directory and get a measurable size reduction.

How it works

  • Lossless mode: uses optimize=True and compress_level=9, typically reducing size by 1-30%. It suits screenshots, UI captures, and text-heavy images where sharpness matters.
  • Lossy mode: quantizes to 256 colors with Image.Quantize.MEDIANCUT, then saves with optimize=True, typically reducing size by 50-80%. It suits photos, gradients, or images where smaller file size is the priority.
  • Batch processing: pass a directory to process PNGs in a folder. compress_png.py supports arguments such as --output, --overwrite, and --lossy, making it easier to write results to a target path or replace originals.
  • Result reporting: after compression, it reports original size, compressed size, and savings percentage for quick validation.

Scope and cautions

This skill covers PNG compression only; it does not resize, reformat, or alter image content. If the user does not specify a mode, ask whether lossless or lossy is preferred. For color-critical images or images with many color layers, prefer lossless mode. Lossy mode reduces the number of colors, so visual results depend on the image content.

Use Cases

  • Compress an oversized PNG screenshot before sending it to a collaborator, choosing lossless or lossy based on the need.
  • Batch-compress PNG assets in a folder, write results to an output directory, and report savings.
  • Keep text and UI edges sharp in a PNG screenshot by using lossless compression and checking the reduction.
  • Reduce photo-like PNGs with 256-color lossy compression when visual changes are acceptable.

Best For

  • Frontend or QA engineers who need to compress UI screenshots for bug reports or docs.
  • Design collaborators who need to shrink multiple PNG assets before packaging or sharing.
  • Data labeling or asset-curation staff who need batch PNG compression with output tracking.
  • Indie developers who need to reduce PNG screenshot or demo image weight quickly.