请参阅我提供的该代码,以识别我在代码中制作枕头GIF时所犯的错误
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)
答案 0 :(得分:0)
只需使用append_images
而不是append_all
:
frames[0].save('gif_1.gif', format='GIF', append_images=frames[1:], ...
(请参阅:https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#saving)