Converting GIFs with Python Image Library

Geoff Gerrietts geoff at gerrietts.net
Tue Nov 4 12:20:14 EST 2003


Quoting Lars (larsdoer at yahoo.com):
> im = Image.open('yahoo.gif')
> im.convert('RGB')
> 
> im.save('yahoo.jpg', 'JPEG')

>>> from PIL import Image
>>> p = Image.open("yahoo.gif")
>>> i = p.convert("RGBA")
>>> bg = Image.new("RGBA", i.size)
>>> i2 = Image.composite(i, bg, i)
>>> i2.save("yahoo.jpg")

Use the optional "colour" argument to Image.new() to choose your
background color.

--G.

-- 
Geoff Gerrietts         "He was a great patriot, a humanitarian, a loyal friend;
<geoff at gerrietts.net>                  providing, of course, he really is dead."
http://www.gerrietts.net/                                           --Voltaire





More information about the Python-list mailing list