Python PIL | ImagePalette() Method
Last Updated :
26 Jul, 2019
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:
from PIL import Image, ImagePalette
im = Image. open (r "C:\Users\System-Pc\Desktop\python.png" )
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:
from PIL import Image, ImagePalette
im = Image. open (r "C:\Users\System-Pc\Desktop\scene4.jpg" )
im1 = ImagePalette.ImagePalette(mode = 'RGB' , palette = None , size = 0 )
print (im1)
|
Output:
PIL.ImagePalette.ImagePalette object at 0x000001B8808AFCC0
Share your thoughts in the comments
Please Login to comment...