GIFImage - 0.9a
This library adds GIF animation playback to pygame.
Also provided are ways to manipulate the animation playback, by setting regions to play, reversing etc.
ATM there is a potential bug where some gif's may not have their palette's set correctly (either some/all frames will be completely black, or they will be jarbled)
If you encounter this, please post here, with a link to the gif (if possible)
Also note, the gifs included are not mine, the football one was a free one from some site, and the hulk is from a tutorial I found on using PIL gifs.
Pygame.org account Comments
Patrick 2012-06-14 21:42:42
Hey, I was using your GIFImage module, and it worked okay. However, like you said, there's some really weird bugs in some of the GIF's. For example, this one right here: http://sprites.pokecheck.org/i... works perfectly fine within browsers and what not, but when I attempt to render it via GIFImage, half the frames are corrupted and some are even blank.
When I split the GIF files into separate frames (png), it shows all the corrupted frames. Viewing it thru other programs like IE, or even Windows Photo Viewer, doesn't show the corrupted frames.
Any help is appreciated!
Scott 2012-11-13 13:07:38
I'm not sure, but I would get a couple of open source image converters. Then try loading and saving the images.
When images load corrupted (but they're not, really) it's because the software doesn't support some attribute found in the image (palate encoding, image headers, packbits vs. LZW compression vs uncompressed, etc.)
It may be that the Pygame library doesn't handle Packbits compression, due to historical and legal reasons. But conversion will work...
John 2013-06-29 00:56:12
Any chance you could upload this file again? Both links are no longer valid.
Thanks in advance, and I appreciate your time!
Matt Roe 2014-10-05 00:08:21
Updating I think i a sec!
NHD 2014-11-29 14:31:05
Hello, your library is awesome, but unfortunately, I came across with some gifs having their frames jarbled. Here is one that has this problem. http://www.feplanet.net/sprite...
(Actually, many gifs in that website have the same issue, however it doesn't seem that you're going to updage GIFImage anymore.)
Hope you can help anyway :)
Ryan 2016-08-19 19:03:09
If you're trying to use this but some of the frames are jarbled or all black, try converting the color profile of the image to something else. GIMP's builtin RGB profile works well with this module as well as pygame.image. I've been having trouble with Photoshop's default color profiles.
Nick Sandau 2016-12-21 22:52:40
So, I'm guessing that this is no longer being maintained - but I've added a bit of functionality (image scaling and playback control) to the class. It's really not much but this library was really useful to me and I'd like to give back a bit. Is there any way I can post my changes so that others can benefit?
Todd Roberts 2016-12-23 03:20:25
Nick, I'm new here, but I'd just paste the code into a github repo and link it here in the comments. Did you encounter any problems with miscolored/jarbled GIFs using this by any chance? My gifs aren't working correctly, though hopefully I'll be able to figure out what the issue is in PIL's GifImagePlugin soon.
Nick Sandau 2016-12-23 15:35:13
Yes, I've run into that. At first blush, on some images it looks to be a problem with how the pallet data is being read from the source file. I think a couple of other posters have also alluded to it being a pallet issue. I'm no expert on GIFs - I've read the RFCs but knowledge != working knowledge. Time permitting I'll look into it. Todd, feel free to throw in your two cents regarding that. Here's the git:
Todd Roberts 2016-12-23 21:11:42
Well, I've just solved my personal issue outside of the code by changing the mode of the GIFs from RGB to Indexed in Gimp. When I print the indexed base_palette from GIFImage, I get the correct rgb color codes for each color in the image. Once they've all been listed, the list continues with values starting at the first unused index, and from there the values are [16, 16, 16], [17, 17, 17], [18, 18, 18], etc. all the way to [255, 255, 255].
With the rgb list, however, the list ends with many [0, 0, 0] values instead. Not sure if this helps as I'm new to programming, but maybe you can make some sense of it.
This also might have something to do with the number of colors in the image? My original image was 64 X 64 and used a small amount of colors. When I made it into a GIF originally, I enlarged it 2x, which added a lot more colors and changed the color mode. Anyway, it renders correctly now but my program seems to be unresponsive.
Ben 2019-04-15 10:55:23.431617Hi, Here is a link to a GIF I tried to open, but the colour palette turned out blue. Other GIFs open fine though. Here is the link: https://preview.redd.it/60d8yyvwg2s21.gif?format=mp4&s=5e9c2e4198209c58933bb70d0aaa7071cfb44a60
Max Benningfield 2019-05-10 00:00:56.391745Hi, I keep getting an error which says: AttributeError: 'Image' object has no attribute 'tile'. I do not know how to fix it. Thanks