PIL Gotcha maybe?

Fredrik Lundh fredrik at pythonware.com
Wed May 2 12:53:08 EDT 2001


Robin Becker wrote:
> >It looks dithered.  I presume that by default the GIF PIL plugin uses
> >the Web palette; your color isn't exactly represented in that palette,
> >so it's dithering it in the output.
> >
> I thought so too, but dithering isn't done to BMP, TIFF etc and I've no
> idea how to turn it off.

BMP, TIFF, etc support 24-bit truecolor images ("RGB").
GIF doesn't, so it converts the image to "P" on the way
out.

adding this line before im.save might work (untested):

    im = im.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE)

Cheers /F





More information about the Python-list mailing list