omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    4
    21
    12865
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NoBetterName
      NoBetterName last edited by

      I also tried this one: http://bestanimations.com/Animals/Mammals/Horses/horse-walking-animated-gif1.gif

      Very simple, trotting horses. Not much memory space.

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by cvp

        Downloaded it, then imported in Pythonista (+, import photo, no need to use a Photos script ) and quick look shows the movement.

        1 Reply Last reply Reply Quote 0
        • NoBetterName
          NoBetterName last edited by

          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?

          JonB 1 Reply Last reply Reply Quote 0
          • NoBetterName
            NoBetterName last edited by

            Hold on, made some adjustments...
            It now produces a still image with no animation as a SpriteNode.

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @NoBetterName last edited by

              @NoBetterName Sorry, I've never used scene....I can't help you more.

              1 Reply Last reply Reply Quote 0
              • cvp
                cvp @JonB last edited by

                @JonB Missing import.os and w.present

                1 Reply Last reply Reply Quote 0
                • JonB
                  JonB @NoBetterName last edited by

                  @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?

                  1 Reply Last reply Reply Quote 0
                  • NoBetterName
                    NoBetterName last edited by NoBetterName

                    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.

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp last edited by cvp

                      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....

                      1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp last edited by cvp

                        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

                        1 Reply Last reply Reply Quote 0
                        • NoBetterName
                          NoBetterName last edited by

                          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!

                          1 Reply Last reply Reply Quote 0
                          • ccc
                            ccc last edited by ccc

                            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)
                            
                            1 Reply Last reply Reply Quote 0
                            • ccc
                              ccc last edited by ccc

                              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 the gif.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

                              1 Reply Last reply Reply Quote 1
                              • First post
                                Last post
                              Powered by NodeBB Forums | Contributors