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.


    Manipulating images from camera

    Pythonista
    3
    6
    3527
    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.
    • cgallery
      cgallery last edited by

      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.

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

        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 Doc

        Photos.capture_image takes a photo
        Please read this topic

        And see also photos.Asset.get_ui_image to transform a photo into an ui.Image

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

          @cgallery To convert a PIL.Image to a ui.Image (that can be used with ui.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())
          
          cvp 1 Reply Last reply Reply Quote 1
          • cvp
            cvp @omz last edited by cvp

            @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()"

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

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

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

                @omz ok, Thanks

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