An indexed PNG recolours for free
Most of what this site does is arithmetic over millions of pixels. For one family of files it is arithmetic over a few hundred bytes, and the pixels are never read at all.
What colour type three actually stores
A PNG file is a signature followed by a list of chunks, each one a length, a four-letter type, its data, and a checksum. The header chunk carries the dimensions, the bit depth and a colour type. Colour type two means each pixel holds its own red, green and blue. Colour type six adds an alpha channel. Colour type three means something different in kind: the file carries a table of colours in a chunk called PLTE, at most 256 entries of three bytes each, and every pixel is an index into that table.
Screenshots of interfaces, logos exported from a vector editor, icons, diagrams, charts and anything else made of flat regions are frequently written this way, because a table of a few dozen colours plus one small index per pixel compresses far better than three full channels. The format is doing exactly what it was designed for.
It also means that recolouring such a file is not an image operation. The colours are not in the pixel data. They are in a table that is, at most, 768 bytes long.
| What has to change | Bytes | Pixel data touched |
|---|---|---|
| the palette path | 144 of 144 read, up to 144 written | none |
| the truecolour path | 5,760,000 read and written | all of it |