-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgifs.py
More file actions
18 lines (15 loc) · 666 Bytes
/
gifs.py
File metadata and controls
18 lines (15 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import glob
from PIL import Image
import numpy as np
FPATH = "generated_im/*.png"
ENDING_FRAMES = 50
FRAME_TIME = 110
START_FRAME = 1 # 0 lub 1
IMAGES_PATHS = glob.glob(FPATH)
names = np.empty(len(IMAGES_PATHS) + ENDING_FRAMES, dtype=object)
for image_path in IMAGES_PATHS:
names[int(str(image_path).replace("generated_im\\", "").replace(".png", "")) - START_FRAME] = image_path
names[len(IMAGES_PATHS):len(IMAGES_PATHS) + ENDING_FRAMES] = names[len(IMAGES_PATHS) - 1]
images = (Image.open(file) for file in names)
image = next(images)
image.save(fp=f"generated_im/gif.gif", format='GIF', append_images=images, save_all=True, duration=FRAME_TIME, loop=0)