I'd like to change the loop header value of a gif animation, specifically this one:
attribution: Gonfer at en.wikipedia
I am attempting to use the python imaging library, PIL, and have come up with the following based on another question.
import PIL as p
a=p.Image.open('Unfasor.gif')
loop = a.info['loop']
a.save('out.gif',loop=10)
This re-saves the gif but it is no longer animated.
Note the value of the loop attribute is presently 0:
>>> a.info
{'duration': 0, 'version': 'GIF89a', 'loop': 0, 'extension': ('NETSCAPE2.0', 27L)}
How can I export as a working animated gif, with a non-zero loop value? I am open to using other libraries.
Note. The reason that I am doing this is that I'd like to put the image into a powerpoint-2007 presentation and have seen suggestions that this loop value is a limiting factor.
I came across a similar issue with changing the loop count of an apng file.
According to the Pillow documentation:
save_all If present and true, all frames of the image will be saved. If not, then only the first frame of a multiframe image will be saved.
from PIL import Image as PillowImage
with PillowImage.open('./image/001.png') as image:
loop = image.info['loop']
image.save('out.png', save_all=True,loop=0)
By applying the save_all
parameter, the apng can now loop as many times as you want.