![]() Imageio.mimsave(os.path.join('movie.gif'), images, duration = 0.04) # modify duration as neededĪs one member mentioned above, imageio is a great way to do this. ![]() imageio also allows you to set the frame rate, and I actually wrote a function in Python that allows you to set a hold on the final frame. How to make a GIF using Python import matplotlib.pyplot as pltĭef gif_maker(gif_name,png_dir,gif_indx,num_gifs,dpi=90): I use this function for scientific animations where looping is useful but immediate restart isn't. ![]() Sorted_files = sorted(image_file_names, key=lambda y: int(y.split('_')))įrame_length = 0.5 # seconds between framesĮnd_pause = 4 # seconds to stay on last frame Plt.close('all') # comment this out if you're just updating the x,y data # lower dpi gives a smaller, grainier GIF higher dpi gives larger, clearer GIF # make png path if it doesn't exist already #CARTOON BIG MAC WRAPPER OPEN HOW TO# Imageio.mimsave(gif_name, images,'GIF',duration=frame_length)Ī simple function that makes GIFs: import imageioĭef make_gif(image_directory: pathlib.Path, frames_per_second: float, **kwargs): # the duration is the time spent on each image (1/duration is frame rate) # loop through files, join them to image array, and write to GIF called 'wind_turbine_dist.gif'įile_path = os.path.join(png_dir, sorted_files)įor jj in range(0,int(end_pause/frame_length)):
0 Comments
Leave a Reply. |