Pixels; colour depth and file size
How File Size is Calculated for a Bitmap
A bitmap stores a colour value for every single pixel in the image. The amount of storage required therefore depends directly on two things: how many pixels there are, and how many bits are needed to store each pixel's colour. This gives the following formula:
Divide by 8 to convert bits to bytes.
Both factors - pixel count and colour depth - multiply directly into the file size. Doubling either one exactly doubles the file size. The worked examples below show how each factor independently drives storage requirements.
Worked Examples
Increasing Pixel Count
Colour depth is fixed at 8 bits per pixel. Doubling the image dimensions quadruples the total pixel count, because both width and height double simultaneously.
| Image size | Total pixels | Colour depth | File size (bits) | File size (bytes) |
|---|---|---|---|---|
| 100 × 100 | 10,000 | 8 bits | 10,000 × 8 = 80,000 | 80,000 ÷ 8 = 10,000 B |
| 200 × 200 | 40,000 | 8 bits | 40,000 × 8 = 320,000 | 320,000 ÷ 8 = 40,000 B |
Doubling both dimensions increases the file size by a factor of 4 (from 10,000 B to 40,000 B). This is because total pixel count scales with the product of width and height - doubling each dimension squares the pixel count.
Increasing Colour Depth
Image size is fixed at 100 × 100 pixels. Increasing colour depth increases the bits needed per pixel, directly scaling the total file size.
| Image size | Total pixels | Colour depth | File size (bits) | File size (bytes) |
|---|---|---|---|---|
| 100 × 100 | 10,000 | 1 bit | 10,000 × 1 = 10,000 | 10,000 ÷ 8 = 1,250 B |
| 100 × 100 | 10,000 | 8 bits | 10,000 × 8 = 80,000 | 80,000 ÷ 8 = 10,000 B |
| 100 × 100 | 10,000 | 24 bits | 10,000 × 24 = 240,000 | 240,000 ÷ 8 = 30,000 B |
Moving from 1-bit to 24-bit colour depth multiplies the file size by 24. The relationship is linear: tripling the colour depth triples the file size, with pixel count unchanged throughout.
Config B has 4× the pixels and 3× the colour depth, giving 12× the file size of Config A.
Key Takeaways
- File size (bits) = Width × Height × Colour depth. Divide by 8 to convert to bytes.
- Increasing pixel count (width or height) increases file size proportionally. Doubling both dimensions quadruples the file size because width × height grows with the square.
- Increasing colour depth increases file size proportionally and linearly - tripling colour depth triples the file size.
- Both factors multiply together: a 4× increase in pixels combined with a 3× increase in colour depth produces a 12× increase in file size.
- Higher quality images (more pixels, greater colour depth) are always larger files - there is a trade-off between image quality and storage or transmission requirements.