[Image-SIG] Saving gifs with transparency

Will Stephenson will at stevello.free-online.co.uk
Mon Feb 16 07:34:11 EST 2004


Hello List

I'm using PIL to write text into comic-book style speech bubbles, but I'm 
having difficulty writing transparent gifs.  If you've got this working, 
could you have a look below and see what I'm doing wrong?

I'm using PIL 1.1.4, which should be the first version which doesn't need a 
patch to do this.  I 

1) load a gif with a transparent background, im.info['transparency'] is set
2) draw some (black) text on it on a non transparent area
3) save it out again.  

Even if I just load the gif and save it again without drawing on it, 
transparency is lost.  I'm checking the result using Gimp and KDE image 
viewers as I see XV doesn't support transparency.

This is my test case:

·       im = Image.open( 'seethru.gif' )
·       if im.info.has_key('transparency'):
	·       print im.info['transparency']
·       im.save('newcopy.gif', 'GIF')

Drawing more transparent areas on the image eg:

draw.ellipse((10, 10, 50, 50), outline=im.info['transparency'], 
fill=im.info['transparency'])

just comes out white, too.  

Any help would be greatly appreciated.  I've even checked the source of my 
library to see if it really has the transparency changes in GifImagePlugin!

Will



More information about the Image-SIG mailing list