Sometimes when opening gifs and saving separate frames to files, the frames come out in bad shape. This doesn't happen with all the gifs, but with the ones that does it happens to many frames.
Example
Here's the original gif
Here's the first frame (comes out ok)
Here's the second frame (comes out screwed)
I tried the same thing with two different python modules. First PIL
from PIL import Image
img = Image.open('pigs.gif')
counter = 0
collection = []
while True:
try:
img.save('original%d.gif' % counter)
img.seek(img.tell()+1)
counter += 1
except EOFError:
break
Then Wand:
from wand.image import Image
img = Image(filename='pigs.gif')
for i in range(len(img.sequence)):
img2 = Image(img.sequence[i])
img2.save(filename='original%d.gif' % i)
and the same happens with both modules.
What's going on?
P.S.: I have found other people having the same symptoms. However, these solutions (both of which revolve around a bug of PIL which deletes the palette when you do .seek()) didn't solve my problem: Python: Converting GIF frames to PNG and PIL - Convert GIF Frames to JPG