How can I load a GIF animation in pygame? With a web search, I found a severely outdated library called GIFImage. I tried it to do it with 2 pictures but I'm getting stuck because I'm a beginner. I also found something about making animations with Sprites, but no tutorial...

How do I do this?


I think what you mean is, how to load an animated GIF in pygame.

It's true that pygame doesn't support animated GIFs natively, and you'd need GIFImage for that. Not sure how well it works, but I wouldn't recommend it anyway.

This is because in games you usually want to control the animation yourself. Use a spritesheet or separate images for your sprite frames. Then swap out the image in your game. See this question for more details.

For the record, if the GIF isn't animated, it's trivial:

sprite_image = pygame.image.load("image.gif").convert_alpha()
  • \$\begingroup\$ So if some one was interested in using an animated gif in Pygame, not worrying about sprite animations or controlling the animation, where would one find this GIFImage you speak of? It appears the links on pygame.org are all broken. I am using Pygame to load and display images on a screen, no real user interaction required, and would like to include some animated gifs into this, thanks! \$\endgroup\$ – sec_goat Jun 26 '14 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.