我得到了一个部分透明的图像和一个GIF。
我想用PIL将图片粘贴到GIF上,我得到一个动画GIF作为背景,在前景中有静态图像。
发布于 2018-11-23 20:26:33
你可能需要根据你自己的特定图像来调整它,但这是一个起点-
from PIL import Image, ImageSequence
transparent_foreground = Image.open(...)
animated_gif = Image.open(...)
frames = []
for frame in ImageSequence.Iterator(animated_gif):
frame = frame.copy()
frame.paste(transparent_foreground, mask=transparent_foreground)
frames.append(frame)
frames[0].save('output.gif', save_all=True, append_images=frames[1:])
https://stackoverflow.com/questions/53449511
复制