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.


    Blurry output

    Pythonista
    4
    8
    5308
    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.
    • reefboy1
      reefboy1 last edited by

      Is there a possible way to blur output of a pythonista script? Specifically this one wich needs a UI to run:

      import ui
      import time
      
      def screenshot_action(sender):
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
          time.sleep(1.00)
      
      
      v = ui.load_view()
      v.present('sheet')
      
      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Could you rewrite the code above as:

        import ui
        import time
        
        def screenshot_action(sender):
            v = sender.superview
            for x in xrange(17):  # the next 4 lines should be run 17 times in a row
                with ui.ImageContext(v.width, v.height) as c:
                    v.draw_snapshot()
                    c.get_image().show()
                time.sleep(1.00)
        
        v = ui.load_view()
        v.present('sheet')
        

        Is your question:

        • Is there a way to make all 17 snapshots equally blurry? Or?
        • Is there a way to make each snapshot to be more blurry than the one before it?
        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          http://omz-software.com/pythonista/docs/ios/ImageFilter.html
          would be a good place to start with blur.
          You will need the ui2pil, and maybe pil2ui, from this thread

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

            Is there a way to make all 17 snapshots equally blurry

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

              @JonB , the examples at the site don't seem to work in pythonista for me :/

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

                Which examples? The ImageFilter ones? You need to first open an actual image (the examples assume you have an Image object im. Obviously you would also need to import ImageFilter

                import Image, ImageFilter, io
                # ... Insert looping code, etc from ccc's code
                with ui.ImageContext(v.width, v.height) as c:
                    v.draw_snapshot()
                    uiimg=c.get_image()
                    pilimg=Image.open(io.BytesIO(uiimg.to_png()))
                    pilimg.filter(ImageFilter.BLUR).show()
                

                works in ccc's code above

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

                  Is there a simple way to "capture" programmaticky the current screen or other views? That and this discussion would allow for a a more "tricked out" version of my shield class

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

                    Ahh... Blur out the shielded components? Neat idea.

                    You can capture a screenie of a view, which is what draw_snapshot does. Just replace v with whatever component you want to grab. rather than show(), you'll want to use the pil2ui function to get a ui compatible image, which you could set to an imageview's image.

                    Also, you might experiment with ImageFilter.GaussianBlur, which looks nicer than BLUR to me. It seems to ignore the radius input parameter. Might be too slow for shield if you are blurring large images.

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