Skip to content

Commit

Permalink
Update compose_gif.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Vis6 committed Apr 25, 2021
1 parent 20a9acf commit 9ee12e9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions compose_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@
import glob


def compose_gif(img_path, duration=1.0):
def compose_gif(img_path, duration=0.1):
gif_name = img_path.split('/')[-1]
file_paths = glob.glob(pathname='%s/*.jpg' % img_path)
file_num = len(file_paths)

frames = []
for i in range(file_num):
frames.append(imageio.imread('%s/%d.jpg' % (img_path, i)))
imageio.mimsave('./gif/%s.gif' % gif_name, frames, 'GIF', duration=duration)
if i % 10 == 0: # read for every 10 frames
frames.append(imageio.imread('%s/%d.jpg' % (img_path, i)))
if i == file_num - 1: # read the last frame
frames.append(imageio.imread('%s/%d.jpg' % (img_path, i)))
duration_list = [duration] * len(frames)
duration_list[-1] = 3.0
imageio.mimsave('./gif/%s.gif' % gif_name, frames, 'GIF', duration=duration_list)


if __name__ == '__main__':
make_a_star_gif = True
make_rrt_gif = True

if make_a_star_gif:
compose_gif(img_path='./gif/a_star', duration=0.1)
compose_gif(img_path='./gif/a_star')
if make_rrt_gif:
compose_gif(img_path='./gif/rrt', duration=0.1)
compose_gif(img_path='./gif/rrt')

0 comments on commit 9ee12e9

Please sign in to comment.