Forum Archive

Problems with opening Image PIL

kami

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:


not working:

Can someone tell me what my problem is?

Thx a lot.

Cu kami

cvp

@kami perhaps a solution here

kami

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

mikael

@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

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