首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Pillow制作GIF

无法使用Pillow制作GIF
EN

Stack Overflow用户
提问于 2020-08-10 16:33:45
回答 1查看 74关注 0票数 0

请看我提供的这段代码,以识别我在代码中制作GIF的错误

代码语言:javascript
复制
from PIL import Image, ImageDraw

def make_Image(w,h,p_1,p_2):
    
    img = Image.new('RGB', (w,h), (255,255,255))

    draw = ImageDraw.Draw(img)

    draw.rectangle([(p_1,p_2), (p_1+10,p_2+10)], fill = 'red', outline = 'blue')

    return img 

frames = []

x,y = 0,0

for i in range(10):

    new_image = make_Image(200,200,x,y)

    x = x + 20

    y = y + 20

    frames.append(new_image)

frames[0].save('gif_1.gif', format = 'GIF', append_all = frames[1:], save_all = True, duration = 1, loop = 0)
EN

回答 1

Stack Overflow用户

发布于 2020-08-14 06:08:12

只需使用append_images而不是append_all

代码语言:javascript
复制
frames[0].save('gif_1.gif', format='GIF', append_images=frames[1:], ...

(请参阅:https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#saving)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63336744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档