制作gif图一例_合成gif_制作gif

0 Comments

python制作gif合成gif

python制作gif合成gif

"""
   制作gif图一例
"""
from PIL import Image, ImageDraw

images = []

width = 200
center = width // 2
color_1 = (0, 110, 110)
color_2 = (0, 255, 0)
max_radius = int(center * 1.5)
step = 8

for i in range(0, max_radius, step):
    im = Image.new('RGB', (width, width), color_1)
    draw = ImageDraw.Draw(im)
    draw.ellipse((center - i, center - i, center + i, center + i), fill=color_2)
    images.append(im)

for i in range(0, max_radius, step):
    im = Image.new('RGB', (width, width), color_2)
    draw = ImageDraw.Draw(im)
    draw.ellipse((center - i, center - i, center + i, center + i), fill=color_1)
    images.append(im)

images[0].save('合成.gif',save_all=True, append_images=images[1:],
               optimize=False, duration=40, loop=0)

标签:,

发表评论