Python PIL | ImagePalette() Method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImagePalette module contains a class of the same name to represent the color palette of palette mapped images.
This module was never well-documented. It hasn’t changed since 2001, though, so it’s probably safe for you to read the source code and puzzle out the internals if you need to. The ImagePalette class has several methods, but they are all “experimental.”
The ImagePalette.ImagePalette() Color palette for palette mapped images.
Syntax: PIL.ImagePalette.ImagePalette(mode=’RGB’, palette=None, size=0)
Parameters:
mode – The mode to use for the Palette.
palette – An optional palette.
size – An optional palette size. If given, it cannot be equal to or greater than 256. Defaults to 0.Return:: The ImagePalette object.
Image Used:
# importing Image module from PIL package from PIL import Image, ImagePalette # opening a image im = Image.open(r"C:\Users\System-Pc\Desktop\python.png") # ImagePalette im1 = ImagePalette.ImagePalette(mode ='RGB', palette = None, size = 0) print(im1) |
Output:
PIL.ImagePalette.ImagePalette object at 0x000001930723FC50
Another Example: take another image with .JPG extension.
Image Used:

# importing Image module from PIL package from PIL import Image, ImagePalette # opening a image im = Image.open(r"C:\Users\System-Pc\Desktop\scene4.jpg") # ImagePalette im1 = ImagePalette.ImagePalette(mode ='RGB', palette = None, size = 0) print(im1) |
Output:
PIL.ImagePalette.ImagePalette object at 0x000001B8808AFCC0
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.getlogin() method
- Python | os.waitid() method
- Python | os.sched_get_priority_min() method
- Python Dictionary | pop() method
- Python | sympy.apart() method
- Python | os.WIFEXITED() method
- Python | os.open() method
- Python | Tensorflow cos() method
- Python | hasattr() method
- Python | sympy.Add() method
- Python | os.getenv() 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.



