2021年3月25日星期四

Animated GIF with Python and imagio Returns Non-Sequential Animation

I have a directory of 180 images. I can use Python and imageio to produce an animated GIF. Trouble is, the animation is blocky (jumps around) and does not appear to start at the first image in the directory. I can confirm that the files are named such that each file (by descending name sort order) are in the sequence that I like. I have tried a variety of duration times from 0.01 to 20. I have tried to run only 20 images but this did not help either.

Why is my animated GIF not working correctly?

import imageio  try:      inDir = '/home/gerry/trimmed'      out_gif_name = 'mount_rainier_animation.gif'      out_gif_path = inDir + '/' + out_gif_name      duration_between_frames = 0.2        with imageio.get_writer(out_gif_path, mode='I', duration=duration_between_frames) as writer:          for (dirpath, dirnames, filenames) in os.walk(inDir):              for inFile in filenames:                 image = imageio.imread(inDir +'/'+ inFile)                 writer.append_data(image)  except:      tb = sys.exc_info()[2]      tbinfo = traceback.format_tb(tb)[0]      print ("PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]))  

You can get the animated GIF from Dropbox here.

https://stackoverflow.com/questions/66808909/animated-gif-with-python-and-imagio-returns-non-sequential-animation March 26, 2021 at 07:20AM

没有评论:

发表评论