[Image-SIG] Saving gifs with transparency
Will Stephenson
lists at stevello.free-online.co.uk
Mon Feb 16 18:01:54 EST 2004
On Monday 16 February 2004 15:00, Will Stephenson wrote:
> On Monday 16 February 2004 12:34, Will Stephenson wrote:
> > 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.
>
> The plot thickens. I had a look at GifImagePlugin, and noticed there was
> an option to use an external module to save the gif and a check to see if
> there is a key 'transparency' in the im.encoderinfo dictionary, so I added
> some debug prints to see what was going on there.
More GifImagePlugin internals:
I discovered that the contents of im.encoderinfo determine whether or not the
transparency chunk/block/header gets written, and this dictionary is
initialised with the 'options' argument to Image.save.
Back in my script, I got PIL to write transparent gifs by passing the contents
of im.info back in via 'options':
im.save( outfile, 'GIF',
transparency=im.info['transparency'] )
So does anyone know why I'm having to jump through these hoops just to
preserve the image's existing transparency? PIL is a good library - I've
managed to pick enough up to achieve my needs with it in half a day - so I
hope I'm just getting something monumentally wrong.
regards
Will
--
Will Stephenson
IRC: Bille
More information about the Image-SIG
mailing list