save animated GIF in Python Image Library

C

christof hoeke

hi,
how can i save an animated GIF with PIL?

e.g. to rotate all frames of an image i tried the following:

im = Image.open('anim.gif')
for f in ImageSequence(im): #using the class from the PIL handbook
if f:
f = f.rotate(180)
im.save('animrotated.gif')

problem is that only one frame (i guess the last one) is saved.
i could not find any options for saving GIFs in the handbook.

can this be done at all?

thanks
christof
 
F

Fredrik Lundh

christof hoeke said:
how can i save an animated GIF with PIL?

e.g. to rotate all frames of an image i tried the following:

im = Image.open('anim.gif')
for f in ImageSequence(im): #using the class from the PIL handbook
if f:
f = f.rotate(180)
im.save('animrotated.gif')

problem is that only one frame (i guess the last one) is saved.
i could not find any options for saving GIFs in the handbook.

can this be done at all?

see the "gifmaker" example in the Scripts directory.

(get the PIL source distribution if you don't have it)

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top