Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Display gif
-
I also tried this one: http://bestanimations.com/Animals/Mammals/Horses/horse-walking-animated-gif1.gif
Very simple, trotting horses. Not much memory space.
-
Downloaded it, then imported in Pythonista (+, import photo, no need to use a Photos script ) and quick look shows the movement.
-
1: Thanks for that, @cvp. I didn't even know that was there. How stupid of me; I have used Pythonista for several years now, and have never used anything in that menu except for add script, pyui file, and txt file.
2: It returns an IOError when I try to make a SpriteNode out of it. What now?
-
Hold on, made some adjustments...
It now produces a still image with no animation as a SpriteNode. -
@NoBetterName Sorry, I've never used scene....I can't help you more.
-
@JonB Missing import.os and w.present
-
@NoBetterName Since we don't have either your code, or a full traceback, how can we possibly help debug your code! Paste a minimal example that shows the issue, (using three backticks to format code), and paste a full traceback.
Are you using the GifSpriteNode git?
-
Oh, sorry about that. Right now, I'm just trying to fix a simplified, very basic, gif-SpriteNode thing-a-ma-bobby. This is my code:
from scene import * class MyScene(Scene): def setup(self): img = 'horsegif.GIF' texture = Texture(img) background = SpriteNode(texture) background.size = self.size background.anchor_point = 0,0 background.position = 0,0 self.add_child(background) run(MyScene())
It isnt much.
By that way, the adjustment that I made earlier was just making the Texture from a file path instead of a ui.Image of the gif file. I don't know why it changed the results... I'm a bit clueless when it comes to gifs.
-
Perhaps, I say perhaps because I really don't know anything about scene, you could use image2gif to extract an array of PIL images (via readGif) and display each frame when scene runs....
-
You could also extract frames of your gif online, by example here and download a zip with all the frames, and then process it locally
-
Problem with that, scene runs 60 times per second. Way too fast. I used the example above to process a gif and add it to a scene. Thanks @ccc!
I devised a switch system to slow down a gif if it goes too fast, as it seems that the gif @ccc referred to did something similar to your idea, @cvp. Thanks for all the help guys, and hopefully you will see this app on the App Store sometime soon! -
get_horse.py
...import console, requests url = 'http://bestanimations.com/Animals/Mammals/Horses/horse-walking-animated-gif1.gif' # url = 'http://fc00.deviantart.net/fs71/f/2012/189/a/a/dressage_horse_animation_by_lauwiie1993-d56it04.gif' filename = url.split('/')[-1] with open(filename, 'wb') as out_file: out_file.write(requests.get(url).content) console.quicklook(filename)
-
I tried to remove as many class attributes from
GifSpriteNode
as possible to simplify/streamline the class. Perhaps a bit too radical. ;-) The duration is now hard coded because I did not find thegif.info['duration']
values to be very helpful. The commented URL seems to have a palette issue on one frame.https://github.com/balachandrana/animating_gif_in_pythonista_scene/blob/master/GifSpriteNodeHorse.py