PNG Quantizer

Uploads a PNG, decodes it onto an off-screen canvas, and reduces it to at most a chosen number of colors using a popularity-based quantization algorithm that maps every pixel to its nearest palette entry, then lets you download the quantized PNG. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool reduces a PNG down to a small, fixed number of colors using a popularity-based quantization algorithm, entirely in your browser.

It works on a plain pixel buffer, so nothing you upload is sent to a server.

What Is PNG Quantizer?

A color quantization tool that builds a single global palette of the image's most common colors and remaps every pixel to its closest palette entry by RGB distance.

Unlike per-channel posterization, this produces a palette of genuine, real colors pulled directly from the image's own most frequent tones.

How PNG Quantizer Works

Every pixel's color is bucketed into a coarse 5-bit-per-channel histogram; the most frequently occurring buckets, up to the requested color count, become the output palette using each bucket's true average color.

Every pixel is then remapped to whichever palette color is closest to it in RGB space (by squared Euclidean distance), so the final image never uses more than the requested number of distinct colors.

When To Use PNG Quantizer

Use it to prepare an image for a format or medium with a hard color limit, or to create a deliberately simplified, poster-like version of a photo.

It's also a useful first step before further palette-based editing or exporting to formats like GIF that rely on a limited color table.

Features

Advantages

  • Runs entirely client-side; nothing you upload leaves your device.
  • Uses the image's own most common colors rather than an arbitrary fixed grid, producing more visually faithful results than uniform per-channel banding.
  • Guarantees the output never exceeds the requested color count.

Limitations

  • Color count is capped at 64 to keep the nearest-palette pixel search fast; it isn't meant for extremely large palettes.
  • Very large images can take noticeably longer to process than simpler per-pixel filters, since each pixel is compared against every palette entry.

Examples

Simplify a photo to 8 colors

Input

A 300x300 color photo PNG, colorCount 8

Output

A 300x300 PNG using only 8 distinct colors pulled from the photo's own palette

The 8 most frequent color buckets become the palette, and every pixel snaps to its nearest one.

Preserve a near-solid graphic exactly

Input

A 100x100 two-tone logo PNG, colorCount 4

Output

The same 100x100 logo, visually unchanged since it already had fewer than 4 colors

When the source has fewer distinct colors than the requested count, quantization has little to no visible effect.

Best Practices & Notes

Best Practices

  • Use a higher color count (24-64) for photos to keep them recognizable, and a lower count (2-8) for a deliberately stylized, poster-like effect.
  • Pair with the dithering adder afterward if flat color bands look too harsh.

Developer Notes

The lib function's popularity histogram uses a coarse 5-bit-per-channel bucket key to bound memory use, then does an O(pixels x paletteSize) nearest-color search capped by the 64-color maximum to keep runtime reasonable even on large images, distinct from `reducePngColorCount`'s O(pixels) per-channel banding approach.

PNG Quantizer Use Cases

  • Preparing an image for a limited-palette export format
  • Creating a simplified, poster-like version of a photo
  • Extracting and applying a small representative palette back onto the source image

Common Mistakes

  • Expecting per-channel banding like posterizing produces — quantization here picks whole colors, not independent channel steps.
  • Requesting a very high color count on a large image and being surprised it takes a moment to process.

Tips

  • Try a modest color count (16-32) first for photos; it's often visually close to the original while meaningfully reducing complexity.
  • Use a very low count (2-4) deliberately for a bold, graphic poster effect.

References

Frequently Asked Questions