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.
Manipulating images from camera
-
I'm trying to take a pic from the camera and display it in the UI without first saving the picture to a roll. So I'm trying to accomplish something similar to this:
raw_photo = photos.pick_image(raw_data=True)
image.image = ui.Image.from_data(raw_photo)But the camera apparently returns PIL.image object, so I need a way to convert that to something that can be used in the ui?
Any tips here?
I've only been using Pythonista for a few hours and I'm loving it. Addicted, I am.
-
Pick_image does not take a photo but allows you to select photo(s) from the camera roll, thus photos already taken.
This method is marked as deprecated in the DocPhotos.capture_image takes a photo
Please read this topicAnd see also photos.Asset.get_ui_image to transform a photo into an ui.Image
-
@cgallery To convert a
PIL.Image
to aui.Image
(that can be used withui.ImageView
), you can use something like this:import io data_buffer = io.BytesIO() img.save(data_buffer, 'PNG') ui_img = ui.Image.from_data(data_buffer.getvalue())
-
@omz in your doc you write:
"Assets only contain metadata, so to get an actual image, you’ll have to use the Asset.get_image() function, as shown in the example above. The image is returned as a PIL.Image object. If you want a ui.Image instead, use Asset.get_ui_image()" -
@cvp True, but that only applies to assets in the photo library, not to camera images (which aren't necessarily even saved in the photo library).
-
@omz ok, Thanks