问题描述
我正在使用PIL动态创建GIF,并且在Charizard翅膀的尖端得到了此工件 https://imgur.com/a/GD9wUwR 以下是我用于创建gif的代码,我认为通过将新背景粘贴到gif不会导致此问题,但看起来似乎没有任何作用。
images = []
length = min(pokemonImage1.n_frames,pokemonImage2.n_frames)
for frameIndex in range(0,length):
pokemonImage1.seek(frameIndex)
pokemonImage2.seek(frameIndex)
pkmn1 = pokemonImage1.convert("RGBA")
pkmn2 = pokemonImage2.convert("RGBA")
imageInMemory = BytesIO()
new_img = Image.new('RGBA',(800,400),(0,0))
new_img.paste(background,0))
new_img.paste(pkmn1,(600,100),mask=pkmn1)
new_img.paste(pkmn2,(100,300),mask=pkmn2)
new_img.save(imageInMemory,'png')
imageInMemory.name = "gifInMemory_" + str(frameIndex) + ".png"
images.append(Image.open(imageInMemory))
gifInMemory = BytesIO()
images[0].save(gifInMemory,"gif",save_all=True,append_images=images[1:],loop=0,optimize=True,duration=20)
gifInMemory.name = "battle.gif"
gifInMemory.seek(0)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)