Search code examples
pythonpython-3.xgifanimated-gif

How can I take an existing animated GIF and make it play only once?


I'm relatively new to Python. I have a large group of animated gif files which I need to change from looping forever, to playing only once. Since I already know how to perform operations on multiple files using Python I'm halfway there.

So, is there a way to read the gif, change its setting and then save it?

I'm using python 3 FYI.

EDIT: Umm, if I did something wrong, please respond to let me know. Downvoting me into oblivion doesn't help me.


Solution

  • Check out Pillow and the documentation in its parent library, PIL. Whether a GIF repeats is configured through the Image.info['loop'] property.