-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
What did you do?
I am trying to remake a transparent GIF by loading a GIF, extracting the GIF and appending them to make a GIF again.
What did you expect to happen?
The result would retain the transparency.
What actually happened?
The frames loses its transparency when using alpha_composite.
What are your OS, Python and Pillow versions?
- OS: Windows
- Python: 3.7.4
- Pillow: 7.0.0
from PIL import Image
filename = ''
output_png = ''
output_gif = ''
frames = Image.open(filename)
Image.open(filename).convert('RGBA').save(output_png) # To test that it is indeed transparent per Frame
all_frames = []
for i in range(frames.n_frames):
frames.seek(i)
if i != 0:
curr_frame = frames.convert('RGBA')
disp_frame = Image.alpha_composite(prev_frames, curr_frame) # I think the issue is here
else:
disp_frame = frames.convert('RGBA')
all_frames.append(disp_frame)
prev_frames = frames.convert('RGBA')
all_frames[0].save(output_gif, save_all=True, optimize=True, append_images=all_frames[:], loop=0)