[Image-SIG] Converting to GIF images?

Fredrik Lundh fredrik at pythonware.com
Mon Oct 23 23:10:18 CEST 2006


Gordon Scott wrote:

> I'm trying to use PIL to convert some images to GIF and am having the 
> same problem as everyone else seems to have.
> When converting images from other formats into GIF, the result is rather 
> low quality.

GIF is an utterly crappy format; low quality comes with the territory. 
any reason you cannot use PNG instead?

> After googling and searching the list archives I've seen a few people 
> mention the same problem and that it has to do something with the 
> default palette for PIL uses for GIF images?

it's more often the dithering that's done when you convert RGB images 
(which can contain millions of distinct colors) to GIF (which can con-
tain 256 colors at the most).  you can disable dithering by explicitly
converting the image before you save it:

     im = im.convert("P", dither=False)
     im.save("out.gif")

</F>



More information about the Image-SIG mailing list