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
-
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')
-
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?
-
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 -
Is there a way to make all 17 snapshots equally blurry
-
@JonB , the examples at the site don't seem to work in pythonista for me :/
-
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 ImageFilterimport 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
-
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
-
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'simage
.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.