Real image files whose size you can calculate to the exact byte.
Every image below is a real file, stored as a BMP. A BMP stores every pixel with no compression, so its size is the formula plus a small, fixed amount of metadata: the information that tells the computer how to read the pixels.
Every BMP starts with a 54-byte header holding the width, height, colour depth and file size. Up to 8-bit, it also stores a colour table: the colour index, 4 bytes for every colour available. At 24-bit each pixel stores its own colour, so there is no table.
A colour table can be picked for the picture, choosing the best colours for that image, or it can be a standard table shared by every picture. The emoji below uses a picked table. The eye and the sunset use the standard 8-bit table, which has 8 reds × 8 greens × 4 blues, as early computers and the early web did. Either way the table holds 256 colours, so the metadata is the same size.
| Colour depth | Header | Colour table | Metadata |
|---|---|---|---|
| 1-bit (2 colours) | 54 | 2 × 4 = 8 | 62 bytes |
| 4-bit (16 colours) | 54 | 16 × 4 = 64 | 118 bytes |
| 8-bit (256 colours) | 54 | 256 × 4 = 1,024 | 1,078 bytes |
| 24-bit (16.7 million colours) | 54 | none | 54 bytes |
The pictures are shown enlarged so you can see every pixel. The file you save is the real, tiny one.
Flat blocks of colour, only six of them. Look along the row: from 4-bit up the picture does not change at all, but the file keeps growing. Extra colour depth is wasted on a picture that does not use it.
32 × 32 × 1 ÷ 8 = 128 bytes of pixels
+ 62 bytes of metadata
= 190 bytes
32 × 32 × 4 ÷ 8 = 512 bytes of pixels
+ 118 bytes of metadata
= 630 bytes
32 × 32 × 8 ÷ 8 = 1,024 bytes of pixels
+ 1,078 bytes of metadata
= 2,102 bytes
32 × 32 × 24 ÷ 8 = 3,072 bytes of pixels
+ 54 bytes of metadata
= 3,126 bytes
Drawn in code for this page by Mr Rawson.
A photograph holds thousands of different colours. At 4-bit there are only 16 to go round, so the green iris turns grey. The 8-bit version uses the standard 256-colour table, which brings the green back but turns the skin blotchy. At 24-bit every pixel stores its own exact colour, so the skin is smooth again.
64 × 64 × 1 ÷ 8 = 512 bytes of pixels
+ 62 bytes of metadata
= 574 bytes
64 × 64 × 4 ÷ 8 = 2,048 bytes of pixels
+ 118 bytes of metadata
= 2,166 bytes
64 × 64 × 8 ÷ 8 = 4,096 bytes of pixels
+ 1,078 bytes of metadata
= 5,174 bytes
64 × 64 × 24 ÷ 8 = 12,288 bytes of pixels
+ 54 bytes of metadata
= 12,342 bytes
Generated for this page on Mr Rawson's own computer with an open image model (Z-Image-Turbo, via mflux). It is not a photograph of a real person.
Long smooth blends of colour, from violet through orange to gold. At 4-bit and at 8-bit (the standard 256-colour table) the sky breaks into stripes. At 24-bit the blend is smooth, and the reflection of the sun appears in the water.
64 × 64 × 1 ÷ 8 = 512 bytes of pixels
+ 62 bytes of metadata
= 574 bytes
64 × 64 × 4 ÷ 8 = 2,048 bytes of pixels
+ 118 bytes of metadata
= 2,166 bytes
64 × 64 × 8 ÷ 8 = 4,096 bytes of pixels
+ 1,078 bytes of metadata
= 5,174 bytes
64 × 64 × 24 ÷ 8 = 12,288 bytes of pixels
+ 54 bytes of metadata
= 12,342 bytes
Drawn in code for this page by Mr Rawson.