Colour representation in Pillow


Martin McBride, 2020-09-19
Tags colour rgb transparency greyscale
Categories pillow
In Python libraries

Colour is a vital aspect of computer imaging, of course. Pillow supports various different raster image formats, which in turn support different ways of representing colour:

  • Light and colour - a basic overview of how the human eye detects colour.
  • Colour spaces - colour is most commonly represented as RGB values, but some Pillow also supports several alternatives.
  • Colour depth - modern bitmap image formats typically use 8 bits per colour per pixel to represent colours, but Pillow also supports several alternatives, mainly used by older image formats.

Pillow refers to the combination of a colour space and a colour depth as the mode of the image. Pillow supports a fixed set of modes.