[Image-SIG] GIF paste / mask question

Dave Kelly dk at lucidstrategies.net
Wed Jun 25 14:41:07 EDT 2003

Hello.  I have a widget I've created that displays an animated GIF, and I'm
using PIL to step through and read each frame into a sequence.  The problem
I'm having is that any frames with transparency are not being displayed
correctly...the transparent areas are coming through as whatever color they
are in the palette.  What I think I need to do is get the transparency value
from info['transparency'], and then create a mask out of just those pixels
that are transparent.  Then I can paste each frame onto the previous with
the transparency mask, and it _should_ display correctly.  This is my theory
anyway.  (Which, by the way, if anyone has any insight into the correct way
to display animated GIF frames, I'd love to hear it, because the GIF spec
didn't really help my understanding any...do I layer each one over the
previous, or do I do a full redraw, or just redraw those areas that are

The problem I have is that I really don't understand very well how to
generate a mask...I've looked at the documentation for the Image.point()
command, but I can't seem to make it do what I want.

So say my info['transparency'] value is 56 (arbitrarily).  How would I
generate a mask out of my image so that when I paste, anything  pixels that
map to 56 in the palette table are not pasted?

My widget works great for animated GIF's where each frame is a full picture
the same size as the original.  Unfortunately, not very many animated GIF's
do this...most are compressed and use transparency.

Thanks in advance for any help!!


More information about the Image-SIG mailing list