A pixel is a single coloured point.
Images are made up of thousands or even millions of pixels. The colour of each pixel is stored in binary.
The screen that you're viewing this page on is also made up of pixels.
The colour depth of an image is the number of bits used to store the colour of each pixel.
A black-and-white image would have a 1-bit colour depth, as you only need one bit to choose between two different options (0 = black and 1 = white).
If d is the colour depth of an image, the maximum number of colours you could encode is 2d.
Images usually use a 24-bit colour depth (1 byte each for red, green, and blue). This means the total number of colours is 224 = 16,777,216.
The file size of an image is the total number of bits needed to store the image.
You can work out the file size by using the formula:
file size (in bits) = width (in pixels) × height (in pixels) × colour depth (in bits)
You can then work out the file size in bytes by dividing this answer by 8.
What is the file size in bytes of a 50×100 image with a colour depth of 8 bits?
file size (in bits) = 50 pixels × 100 pixels × 8 bits
= 40,000 bits = 5000 bytes