[Image-SIG] How to generate optimal palettes ?
Martin Renold
martinxyz at gmx.ch
Wed Aug 13 09:21:34 EDT 2003
On Tue, Aug 12, 2003 at 10:42:22PM -0700, Chris Cogdon wrote:
> im3 = im2.convert ( 'P' )
There is an undocumented feature (don't ask me why, I'm just another
random PIL user) to do this:
im3 = im2.convert('P', None, None, Image.ADAPTIVE, 227)
Seems to generate an optimal palette with 227 colors.
The definition in the source code:
def convert(self, mode=None, data=None, dither=None,
palette=WEB, colors=256):
In the python shell, you can type
>>> import Image; help(Image)
And it will show you the path to the file where the definition is.
bye,
Martin
More information about the Image-SIG
mailing list