PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。的ImagePalette
模塊包含一個同名的類,以表示調色板映射圖像的調色板。
這個模塊從來沒有很好的文檔記錄。不過,自2001年以來它就沒有發生過變化,因此您可以安全地閱讀源代碼,並在需要時摸索內部知識。 ImagePalette類有幾種方法,但它們都是“experimental.”
的ImagePalette.ImagePalette()
用於調色板映射圖像的調色板。
用法: PIL.ImagePalette.ImagePalette(mode=’RGB’, palette=None, size=0)
參數:
mode-用於調色板的模式。
palette-可選的調色板。
size-可選的調色板尺寸。如果給定,則該值不能等於或大於256。默認值為0。
返回::ImagePalette對象。
使用的圖片:
# 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)
輸出:
PIL.ImagePalette.ImagePalette object at 0x000001930723FC50
另一個示例:拍攝另一個擴展名為.JPG的圖像。
使用的圖片:
# 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)
輸出:
PIL.ImagePalette.ImagePalette object at 0x000001B8808AFCC0
相關用法
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python PIL eval()用法及代碼示例
- Python sys.getrecursionlimit()用法及代碼示例
- Python sympy.rf()用法及代碼示例
- Python os.waitid()用法及代碼示例
- Python os.WIFEXITED()用法及代碼示例
- Python os.scandir()用法及代碼示例
- Python PIL getpalette()用法及代碼示例
- Python sympy.ff()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python sympy.nT()用法及代碼示例
注:本文由純淨天空篩選整理自Sunitamamgai大神的英文原創作品 Python PIL | ImagePalette() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。