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.
How can I convert a PIL Image to a ui.Image?
-
one thing that helps, not with speed, but with the problem of
capture_image
returning, yet the conversion is not yet complete, is to add an ActivityIndicator which starts animating before starting conversion, and stops animation (and removes the indicator ) afterwards. the ActivityIndicator can be added on top of your imageview, or else it can be added to your root view, and sized to the root view, so that it essentially blocks anything else from happening while the processing happens.on my ipad3, pil2ui takes a second or two for an image captured by the camera... an indicator at least doesn't leave the user wondering if something didn't work right, and prevents you from hitting the capture button again
-
@Webmaster4o: You should start a blog dedicated to problems with PNG images in Pythonista 1.5...except you would have no way to maintain it when 1.6 comes out. Still, it might gain some good traffic until that happens.
@omz: Did you know about these bugs while developing 1.6, or were the fixes just accidents? All this seems quite strange to me.
-
How do I make this support alpha? Using
def pil_to_ui(img): b = BytesIO() img.save(b, "JPEG") data = b.getvalue() b.close() return ui.Image.from_data(data)
Clear turns white...
-
Oops, I feel stupid, JPEG doesn't support transparency XD
-
Why would you use JPEG, you heretic. JPEG has three use cases: photos (the kind you make with your digital camera or smartphone), situations where something else requires you to use JPEG, and memes about lossy image compression.
;)