PIL Get Image Palette
python, python-3.x
Solution
Your `im` has an `im.palette` attribute you could use -- but the recommended approach is instead to call `im.convert(mode)` (you can omit the `mode` argument to let PIL choose it optimally) to have PIL do the palette lookups internally on your behalf, much faster then you could.
Problem
I opened an image and converted it to an image with a 16-color palette using this code: ``` im = Image.open("SomeImage.png") im = im.convert("P") im = im.convert("P", palette = Image.ADAPTIVE, colors = 16) ``` I can get the pixel data using: ``` im.getpixel((x,y)) ``` Which returns an integer corresponding to the index of the color in the palette. How would I get the palette itself as a list of colors?