Another useful operation performed on the image is adjusting the colors within an image. The image may contain one or more bands, containing image data. The image
mode contains information about the depth and type of the image pixel data. The most common modes we will use in this chapter are RGB
(true color, 3x8 bit pixel data), RGBA
(true color with transparency mask, 4x8 bit) and L
(black and white, 8 bit).
In PIL, you can easily get the information about the bands data within an image. To get the name and number of bands, the getbands()
method of the class Image
can be used. Here, img
is an instance of class Image
.
>>> img.getbands() ('R', 'G', 'B', 'A')