Shawn P. answered 07/22/21
Professional Tutor for Python and other Programming Languages
Typically, color information for images is broken into information on each individual pixel.
Pixels are comprised of three colors: red, green, and blue, or RGB for short. The color you see from each pixel depends on the intensity of each of these three colors. The information stored about these colors is often represented by a set of three whole numbers between 0 and 255. For example, a pixel with a color of pure red would be represented with (255, 0, 0).
The image file then groups all of these sets of three numbers together in such a way that it can keep track of where on the screen the pixel should be displayed. One way this is done, is storing a set of these numbers together in the correct order to form each row, then gathering each of these rows in the correct order to make the full image.
Many image formats use different representations, but what I have described is one of the simplest methods.