Python PIL | getbands() method
Last Updated :
29 Jul, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing
capabilities.
PIL.Image.getbands() method returns a tuple containing the name of each band in the image.For example, getbands on an RGB image returns (“R”, “G”, “B”).
Syntax: PIL.Image.getbands()
Parameters: no arguments
Returns: A tuple containing band names.
from PIL import Image
im1 = Image. open (r "C:\Users\sadow984\Desktop\i3.PNG" )
im2 = im1.getbands()
print (im2)
|
Output:
(‘R’, ‘G’, ‘B’, ‘A’)
Image used above is:
from PIL import Image
im1 = Image. open (r "C:\Users\sadow984\Desktop\r1.PNG" )
im2 = im1.getbands()
print (im2)
|
Output:
(‘P’, )
Image used above is:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...