[Image-SIG] GIF bug

Leo Barnes barnes.leo at gmail.com
Tue Mar 27 15:59:37 CEST 2012


Hi!

I have found a bug in how PIL handles animated GIFs. The GIF in
question contains several frames, where each new frame only overwrites
parts of the previous frame. Unless I explicitly ask PIL to load/show
each frame, PIL completely skips previous frames which means that the
extracted image will contain uninitialized data.

Steps to reproduce:
Image: http://dl.dropbox.com/u/14498565/image0006.gif

#Will show uninitialized data
from PIL import Image
i = Image.open("image0006.gif")
i.seek(1)
j = i.convert("RGBA")
j.show()

#Seems to fix problem with uninitialized data by forcing PIL to load
the previous frame
#(Works most of the time, but does not seem completely reliable. The
image buffer is probably uninitialized and #simply reused which can
work if lucky.)
from PIL import Image
i = Image.open("image0006.gif")
i.load()
i.seek(1)
j = i.convert("RGBA")
j.show()

Best regards,
//Leo


More information about the Image-SIG mailing list