Overview
Introduction
This tool shrinks a PNG's file size entirely in your browser by reducing how many distinct colors it uses, which makes the underlying lossless compression far more effective.
No image is ever uploaded to a server; everything happens on-device via canvas.
What Is PNG Compressor?
A client-side PNG compressor that reads an uploaded image's pixel data, rounds each color channel to a coarser grid of possible values, and cleans up the invisible color data behind fully transparent pixels.
The result is re-encoded as a standard PNG, so it opens anywhere a normal PNG does, just with a smaller file size.
How PNG Compressor Works
Every opaque pixel's red, green, and blue values are rounded to the nearest multiple of a step size derived from the chosen compression level, reducing the total number of distinct colors in the image.
Fully transparent pixels (alpha 0) have their red, green, and blue bytes reset to zero, since their original color is invisible but was still contributing entropy the PNG encoder had to compress.
When To Use PNG Compressor
Use it before publishing a large PNG to the web, when a smaller download matters more than pixel-perfect color fidelity.
It's especially effective on photographic or gradient-heavy PNGs, which tend to have the most redundant near-identical colors to collapse.
Often used alongside PNG File Size Reducer and PNG Quality Changer.
Features
Advantages
- Runs entirely client-side; nothing is uploaded anywhere.
- Stays lossless at the file-format level (still a valid PNG), only the color palette is simplified.
- Adjustable level lets you trade off file size against color fidelity.
Limitations
- This is a pixel-level pre-processing step, not a full re-implementation of a PNG encoder; the actual byte savings depend on the browser's built-in encoder when you download.
- Images with very few colors already (icons, line art) will see minimal size reduction since there's little redundancy to remove.
Examples
Best Practices & Notes
Best Practices
- Start at a moderate level (4-5) and increase only if the file size still needs to shrink further.
- Compare the unique-color count before and after to gauge how much redundancy was actually removed.
Developer Notes
The quantization and transparent-pixel cleanup are pure functions over the Uint8ClampedArray buffer; the lib function also reports a before/after unique-color count (computed with a Set of RGB triples) purely for informational display, since exact compressed byte size depends on the browser's own PNG encoder at download time.
PNG Compressor Use Cases
- Shrinking a large PNG before uploading it to a website
- Reducing bandwidth for PNG assets served to mobile users
- Cleaning up leftover color noise in transparent regions
Common Mistakes
- Assuming this performs the same as a dedicated tool like pngquant or oxipng — it's a simpler, pure-JS pixel quantization step, not a full palette/PNG re-encoder.
- Using the highest level on an image with subtle gradients, which can introduce visible color banding.
Tips
- Check the transparency checker first if you're not sure your image has fully transparent regions worth cleaning up.
- For very large images, try the file size reducer's resolution downscaling instead of or alongside color compression.