-
Notifications
You must be signed in to change notification settings - Fork 0
/
gifMaker.py
28 lines (19 loc) · 828 Bytes
/
gifMaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import imageio
#=====#=====#=====#=====#=====#=====#======#=====#=====#=====#=====#=====#=====#
def createGif(gif_name='./game_of_life.gif', image_path='./images', image_duration=0.10):
image_list = []
# argument with duration of each image in seconds
kargs = { 'duration': image_duration }
# save all image values in a list
file_list = sorted([f for f in os.listdir(image_path) if f.endswith(".jpg") or f.endswith(".png")])
for f in file_list:
image_list.append(imageio.imread(os.path.join(image_path, f)))
# create gif
imageio.mimsave(os.path.join(image_path, gif_name), image_list, **kargs)
# remove all images
for f in file_list:
os.remove(os.path.join(image_path, f))
#=====#=====#=====#=====#=====#=====#======#=====#=====#=====#=====#=====#=====#
if __name__=='__main__':
createGif()