Python PIL | getbands() method
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”).
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.
# Importing Image module from PIL package from PIL import Image # creating a image object im1 = Image.open(r"C:\Users\sadow984\Desktop\i3.PNG") # get bands of image im2 = im1.getbands() # print band names. print(im2) |
chevron_right
filter_none
Output:
(‘R’, ‘G’, ‘B’, ‘A’)
Image used above is:

# Importing Image module from PIL package from PIL import Image # creating a image object im1 = Image.open(r"C:\Users\sadow984\Desktop\r1.PNG") # get bands of image im2 = im1.getbands() # print band names. print(im2) |
chevron_right
filter_none
Output:
(‘P’, )
Image used above is:

Recommended Posts:
- Python PIL | getbands() and getextrema() method
- class method vs static method in Python
- Python | next() method
- Python | set() method
- Python | os.dup() method
- Python | sympy.sec() method
- Python | sympy.gcd() method
- Python | os.fstat() method
- Python PIL | getpalette() Method
- Python | os.unlink() method
- Python | os.chmod method
- Python | os.times() method
- Python | Tensorflow abs() method
- Python | os.chroot() method
- Python | os.scandir() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet


