What Is Palette Matching and How Does It Work?
Updated
Palette matching is the process of remapping every pixel in an image, GIF, or video to the nearest color in a palette you choose. Instead of letting the software decide which colors survive, you supply the exact set of colors — often 4 to 256 of them — and every pixel snaps to its closest match. You'd use it when you need a strict, consistent color identity: pixel art sprites, retro game graphics, a brand-limited GIF, or a video that has to sit inside a fixed set of tones. Browser-based tools such as Palettum run this instantly on images, GIFs, and videos, with import/export of palettes and transparency preservation, so you don't need to install anything.
How palette matching actually works
The core operation is a nearest-color search. For each pixel, the tool measures the distance between that pixel's color and every color in your palette, then replaces the pixel with the closest one. Distance is usually computed in a perceptual color space rather than raw RGB, so the match looks closer to what your eye expects.
A few consequences follow directly from that mechanism:
- Output color count is capped by the palette. A 16-color palette produces an image with at most 16 distinct colors, no matter how many the source had.
- Gradients collapse into bands. Smooth shading becomes visible steps, because intermediate colors get pulled to whichever palette entry is nearest.
- The result is deterministic. The same source and the same palette always produce the same output, which is why it's useful for enforcing a house style across many assets.
Palette matching vs. color quantization vs. dithering
These three get confused because they often appear in the same workflow, but they answer different questions.
| Technique | What it decides | Who controls the colors |
|---|---|---|
| Palette matching | Which palette color each pixel becomes | You supply the palette |
| Color quantization | How to reduce a large color set to a smaller one | The algorithm picks the colors |
| Dithering | How to fake missing colors with patterns | Applied on top of either |
Quantization is what you use when you don't have a palette and want the tool to derive one. Palette matching is what you use when you do have a palette and want strict compliance. Dithering is a separate layer: instead of snapping a pixel to one color, it alternates between two nearby palette colors in a checker or noise pattern to suggest the in-between tone. You can combine dithering with palette matching, but it changes the look from clean flat blocks to a textured, grainy surface.
The basic workflow
The steps are the same whether you're working on a still, an animation, or a clip:
- Import your media. Load the image, GIF, or video you want to convert.
- Load or build a palette. Import an existing palette file, or define the colors yourself. If you're targeting a known platform or console look, use that system's documented palette.
- Apply the match. Every pixel is remapped to the nearest palette entry.
- Preview. Check the result before committing — this is where you catch banding, lost detail, or transparency problems.
- Resize if needed. Scaling down before or after matching changes how much detail survives; matching a large image and then shrinking tends to look cleaner than the reverse.
- Export. Save the result in a format that supports your needs — GIF or video for animation, PNG for stills with transparency.
Palettum supports this loop in the browser with instant preview, palette import/export, resizing, and transparency preservation, so you can iterate on the palette without a round trip through desktop software.
Common pitfalls
Transparency loss. Not every tool treats the alpha channel as a first-class citizen. If your source has transparent regions and the tool ignores alpha, those areas may fill with a palette color. Confirm that transparency is preserved before you export, especially for sprites and logos.
Banding. The fewer colors in your palette, the more obvious the steps between them. If a gradient turns into hard stripes, either add intermediate colors to the palette or apply dithering to soften the transition.
Palette size limits. More colors means a closer match but a weaker retro identity. Very small palettes (4–8 colors) give a strong, stylized look but can destroy fine detail; larger palettes (64–256) preserve more but read as less deliberate. Pick the size based on the aesthetic you're after, not the maximum the tool allows.
Wrong palette for the job. A palette tuned for skin tones will mangle a landscape, and vice versa. If the output looks muddy, the problem is often the palette's color distribution rather than the matching itself.
Animation flicker. In GIFs and video, a palette that's too small can make colors shift frame to frame as the nearest match changes. A slightly larger palette, or a palette derived from the whole clip rather than a single frame, usually stabilizes it.
When to reach for it
Use palette matching when the color set is a requirement, not a suggestion — matching an existing sprite sheet, hitting a retro hardware look, keeping a series of GIFs visually uniform, or forcing footage into a brand's limited colors. If you just want a smaller file or a general retro feel and don't care which specific colors remain, quantization is the lighter-touch choice. If you want the in-between tones to survive, add dithering on top.