Add make_animation()
This commit is contained in:
parent
4496c34fd2
commit
2a2f092f8b
1 changed files with 21 additions and 0 deletions
|
|
@ -14,6 +14,8 @@ import matplotlib.lines as mlines
|
|||
import matplotlib.markers as mmarkers
|
||||
import itertools
|
||||
|
||||
from PIL import Image
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
|
@ -465,3 +467,22 @@ def connect_inset(parent_axes, inset_axes, loc1a=1, loc1b=1, loc2a=2, loc2b=2, *
|
|||
|
||||
|
||||
|
||||
def make_animation(paths, options={}):
|
||||
|
||||
default_options = {
|
||||
'save_folder': '.',
|
||||
'save_filename': 'animation.gif',
|
||||
'fps': 5
|
||||
}
|
||||
|
||||
options = aux.update_options(options=options, default_options=default_options)
|
||||
|
||||
|
||||
frames = []
|
||||
for path in paths:
|
||||
frame = Image.open(path)
|
||||
frames.append(frame)
|
||||
|
||||
frames[0].save(os.path.join(options['save_folder'], options['save_filename']), format='GIF', append_images=frames[1:], save_all=True, duration=(1/options['fps'])*1000, loop=0)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue