-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
GIF degrading after initial frame when import #5837
Copy link
Copy link
Closed
Labels
Description
I'm trying to create a programatic assembler for a variety of animated gifs. I want to do this by grabbing each of the parts (each individually animated) and layering them to create the final GIF. All parts apart from the background have transparency.
from PIL import Image, ImageSequence, GifImagePlugin
import os
bg = Image.open('images/bg/Background Sky.gif')
body = Image.open('images/body/Body Blue.gif')
eyes = Image.open('images/eyes/Eyes Green.gif')
headwear = Image.open('images/headwear/Headwear Party Hat.gif')
frames = []
for idx, frame in enumerate(ImageSequence.Iterator(bg)):
frame = Image.new('RGBA', (640, 640), color=(255,0,0,0))
frame.paste(ImageSequence.Iterator(bg)[idx])
frame.paste(ImageSequence.Iterator(body)[idx], mask=ImageSequence.Iterator(body)[idx].convert("RGBA"))
frame.paste(ImageSequence.Iterator(eyes)[idx], mask=ImageSequence.Iterator(eyes)[idx].convert("RGBA"))
frame.paste(ImageSequence.Iterator(headwear)[idx], mask=ImageSequence.Iterator(headwear)[idx].convert("RGBA"))
frames.append(frame)
print(frames)
#frames[0].save('images/generated/output.gif', save_all=True, append_images=frames[0:])
frames[0].save('images/generated/output.gif', save_all=True, append_images=frames[1:], loop=0)I have tried to set the frame to a copy of the frame within the for loop:
frame = frame.copy()
But this fails also.
Reactions are currently unavailable

