Converting GIFs with Python Image Library

L

Lars

Hi,

I'm using PIL to convert image formats supported by PIL into JPEGs.
When I convert GIFs with transparency, the backgrounds turn out black.
Is there a way to specify the background color when converting images
with transparency?

# PIL 1.1.4
import Image

im = Image.open('yahoo.gif')
im.convert('RGB')

im.save('yahoo.jpg', 'JPEG')

Thanks,
Lars
 
A

Andrew Clover

Is there a way to specify the background color when converting images
with transparency?

Not as far as I am aware, last time I tried at least. I wrote this to
work around the problem:

http://www.doxdesk.com/software/py/gifwriter.html

Deals with transparency, low-bpp and LZW compression (so you may need
a patent licence to use it, depending on where you live). Doesn't deal
with animated GIFs, and is pretty slow (as it's pure-Python). May or may
not fit your needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top