[Image-SIG] Convert "P" image with transparent index to "RGBA"

Elias Fotinis efotinis at yahoo.com
Mon Aug 10 13:47:03 CEST 2009


I'm trying to extract the frames of a GIF as individual images. To do so, I 
keep pasting each frame over the "running total" of the previous frames, 
because areas that do not change are transparent.

Since each GIF frame is a "P" image with a single index as transparency, how 
do we convert that into an "RGBA"? I could loop over the pixels and set the 
alpha manually, but perhaps I'm missing something obvious like:

    assert im.mode == 'P'
    im.convert('RGBA', alphaindex=n)




More information about the Image-SIG mailing list