Luc*_*cas 0 python-imaging-library python-3.x
我得到了一个部分透明的图像和一个 GIF。
我想用 PIL 将图像粘贴到 GIF 上,我得到一个动画 GIF 作为背景,前景中是静态图像。
您可能需要针对自己的特定图像进行调整,但这是一个起点 -
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:])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2708 次 |
| 最近记录: |