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.


    Problems with opening Image PIL

    Pythonista
    3
    5
    1594
    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.
    • kami
      kami last edited by

      Hi,

      i have a working script for opening and resizing Image from my local photo storage. Like this:

              asset = photos.get_asset_with_local_id(file['id'])
              print (asset)
              data = asset.get_image()
              print (data)
              wpercent = (mywidth/float(data.size[0]))
              hsize = int((float(data.size[1])*float(wpercent)))
              data = data.resize((mywidth,hsize))
              imgByteArr = io.BytesIO()
              data.save(imgByteArr, format='JPEG')
      

      Before i updated to IOS 14 everything works fine. Without changing the script, i no can sometimes use this functions and sometimes i get the Error with file has 0 bytes and is truncated.

      Here is the output from the files which are working and which are not working:

      working:

      <Asset A4F64DB3-683C-4514-8B27-ED45763434D7/L0/001 - image (3024 x 4032)>
      <PIL.Image.Image image mode=RGB size=3024x4032 at 0x113C58128>

      not working:
      <Asset 1F758F7F-7F2C-4D78-9B6E-EEBA2134AD45/L0/001 - image (1200 x 1600)>
      <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1200x1600 at 0x1143338D0>

      Can someone tell me what my problem is?

      Thx a lot.

      Cu kami

      cvp mikael 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @kami last edited by

        @kami perhaps a solution here

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

          HI,

          thanks a lot for the answer, but sometimes my script is working. Is there any new feature with the right to access images in iOS14?

          Cu kami

          1 Reply Last reply Reply Quote 0
          • mikael
            mikael @kami last edited by

            @kami, from your output it seems that jpeg images are failing. Maybe you should reload them as PNG? You could also try getting all images with get_ui_image and then convert to PIL PNG.

            Will be slow, though.

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

              @mikael I've tried his code with a lot of jpeg photos, without any error.

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