PerfectVector
Studio
By Irene Kim

Indexed PNG vs. RGB PNG: Check Color and Alpha

Tell indexed PNG from RGB and RGBA PNG, check palette transparency, and see why changing the mode cannot restore a color removed from the palette.

5 min read
On this page

An indexed PNG stores a palette number for each pixel. A truecolor PNG stores the RGB color samples for each pixel, with an optional alpha channel in the RGBA variant. A small palette can store flat artwork exactly if it includes every color and opacity combination the artwork uses. Converting indexed PNG to RGBA preserves the combinations still in the file. Colors discarded during palette reduction are already gone. W3C PNG format specification

For a logo you plan to trace, check the decoded colors, the edge opacity, and any small details first. An indexed file can be a perfectly good source. The decision changes if a previous export dropped an accent or replaced a smooth edge with patterned pixels.

Read the PNG color type

PNG records its color type, the pixel storage format, in the IHDR header. For the three formats in this comparison:

IHDR color typeWhat each pixel storesHow transparency can be stored
2, truecolor RGBRed, green and blue samplesOptional tRNS identifies one fully transparent RGB value
3, indexed colorAn index into a palette of up to 256 entriesOptional tRNS gives alpha values to palette entries
6, truecolor RGBARed, green, blue and alpha samplesAlpha is stored per pixel

A PLTE chunk by itself does not identify an indexed PNG. The PNG format also permits a suggested palette in a truecolor file. Read the color type first. PNG chunk definitions

Use a small script to check the header of a valid PNG. This reads the type without relying on the color mode chosen by an editor when it opens the file.

python3 - image.png <<'PY'
import sys
 
with open(sys.argv[1], "rb") as source:
    header = source.read(26)
if len(header) < 26 or header[:8] != b"\x89PNG\r\n\x1a\n" or header[12:16] != b"IHDR":
    raise SystemExit("Expected a PNG header")
print("PNG color type:", header[25])
PY

Compare the visible pixels before you trace

The same badge can decode identically from indexed and RGBA files. In our 96 × 64 pixel fixture, the palette held four entries: transparent, opaque teal, opaque amber, and half-opaque teal. ImageMagick found zero differing pixels between the indexed and RGBA files. The sample on the teal edge retained an alpha value of 128 out of 255.

Then we replaced the amber palette entry’s pixels with teal and saved the reduced copy as RGBA. The accent stayed teal. Changing the storage format could carry the current pixels forward, but the missing color had to come from a better source. ImageMagick Compare

Matching indexed and RGBA PNG badges beside a reduced version whose amber accent remains missing after RGBA export
The indexed and RGBA copies preserve the same four pixel values. Removing the amber color before export leaves the accent missing.

If you have two exports from the same source, compare copies at the same pixel dimensions. The command below counts differing pixels in the two decoded images under the default exact comparison.

magick compare -metric AE indexed.png rgba.png null:

Inspect the image on a light and a dark background when transparency matters. If the mismatch is visible around the edge, the white halo guide helps distinguish baked light pixels from transparency. For printing, a semitransparent PNG pixel check helps identify partial alpha separately from opaque and transparent regions.

Decide which PNG to trace

Keep the indexed file when the necessary edge and color details are present. If another editor requires RGBA for the next operation, expand a copy and verify that the alpha stayed intact. When you see a lost accent or heavy dithering, compare against the original artwork or the least processed export you can get. The PNG-to-SVG quality guide shows which source details to inspect before tracing.

FAQ

Is indexed PNG lossy?

PNG compression preserves the stored pixels. Choosing a limited palette can change the artwork before compression if some original colors or opacity levels cannot be represented.

Can indexed PNG have partial transparency?

Yes. It can assign a different alpha value to each palette entry. The semitransparent teal in the example has its own entry.

Will converting indexed PNG to RGBA restore missing colors?

No. RGBA expansion changes how the current pixels are stored. Recover the original artwork or re-export from the source project if an earlier palette reduction removed needed colors.

Start with the best available copy

PerfectVector can trace a PNG into editable SVG paths.

If you need editable artwork from a PNG, preview a vector trace with the version that retains the correct edges and colors. Compare the traced accent and openings with the source before you use the SVG.

Sources

  1. W3C PNG specification — PNG color types, palette storage and alpha.
  2. PNG chunk specifications — The IHDR, PLTE and tRNS chunks.
  3. ImageMagick Compare — Pixel differences and the absolute error metric.

More from the blog

PerfectVector

Turn your image file into an
editable SVG

Vectorize and inspect previews for free, with no daily limit.