What is a pixel? Short for "picture element," a pixel is a single point in an image.
Image Size: Measured in pixels (width x height)
Example: An image with a width of 8 pixels and a height of 8 pixels is written as 8x8
, meaning there is 64 pixels in that image
Colour Depth: The number of bits used to represent each pixel
Example: A colour depth of 2 bits means each pixel can have 2^2 = 4
different colours.
Imagine this image of 4 width, 4 height, 2-bit colour depth
2-bit
colour depth means we have 2^2
colours, or 4 colours. In this specific image:
00
is Black01
is Light Grey10
is Dark Grey11
is WhiteHow can we calculate the file-size of this image?
$\text{size in bits (b)} = \text{width} \times \text{height} \times \text{colour bit-depth}$
So, 4 * 4 * 2 = 32 bits
And 8 bits = 1 byte, so this image is 32/8 = 4 bytes
$\text{size in bytes (B)} = \text{width} \times \text{height} \times \text{colour bit-depth} \div 8$
When any of the three increase: width, height or colour bit-depth, the file-size increases, as either more pixels are stored (increase height or width), or more bits are stored per pixel.