+

Python PIL | getbands () method

PIL — is a Python image library that provides the Python interpreter with image editing
capabilities.  The PIL.Image.getbands () method returns a tuple containing the name of each band in the image. For example, it returns getbands on an RGB image ("R", "G", "B").

  Syntax:  PIL.Image.getbands ()  Parameters:  no arguments  Returns:  A tuple containing band names. 

# Import Image module from PIL

from PIL import Image

  
# create an image object

im1 = Image. open (r "C: Userssadow984Desktopi3.PNG" )

 
# get image stripes

im2 = im1.getbands ()

  
# print title groups.

print (im2)

Output:
("R", "G", "B "," A ")

Image used above:

# Import Image module from PIL

from PIL import Image

  
# create image object

im1 = Image. open (r " C: Userssadow984Desktop 1.PNG " )

< p>  
# get image stripes

im2 = im1.getbands ()

  
# print group names.

print (im2)

Exit:
(& # 39; P & # 39 ;,)

Image used above:

Get Solution for free from DataCamp guru