I’m trying to learn the photos module and I’m currently having issued when trying to access an asset. Using the first example in the documentation located here:
http://omz-software.com/pythonista/docs/ios/photos.html
Which looks like this (note I added the last line):
import photos
all_assets = photos.get_assets()
last_asset = all_assets[-1]
img = last_asset.get_image()
img.show()
print(last_asset.location)
I get the following error:
SystemError: <built-in method get_image of _photos2.Asset object at 0x116e8b2a0> returned a result with an error set
and sometimes get this error:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/3E65F849-59EF-4889-9C6A-3ECA00C7FCDF/Pythonista3/Documents/last_photo.py", line 4, in <module>
img = last_asset.get_image()
File "/var/containers/Bundle/Application/F36E1393-51FA-48EB-86DA-20E0386D8BD6/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/PIL/Image.py", line 2313, in open
if not accept or accept(prefix):
File "/var/containers/Bundle/Application/F36E1393-51FA-48EB-86DA-20E0386D8BD6/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/PIL/HeicImagePlugin.py", line 33, in _accept
uti = str(ObjCInstance(c.CGImageSourceGetType(src)))
File "/var/containers/Bundle/Application/F36E1393-51FA-48EB-86DA-20E0386D8BD6/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 547, in __str__
return desc_str.decode('utf-8')
AttributeError: 'NoneType' object has no attribute 'decode'
I was first trying this code on my phone so then I tried running it on my iPad. It worked on my iPad, thinking maybe it was just a problem with my phone (since I'm not real familiar with the errors I was getting) I air dropped a geotagged photo from my phone to my iPad. I then got the the shorter of the aforementioned error. I noticed the photo that originally worked on my iPad was not geotagged while the photo on my phone was. I tried taking a photo on my iPad and I got the error again. I tried turning off geotagging on my phone and air dropping a photo and that still did not work. Finally I realized that the one photo that had worked so far had been edited (I marked some dimensions up on it) so I tried editing a photo by slightly increasing the brightness on my phone. It worked and so far any photo that is not edited will not run with the script, but once a photo is edited in any manner it then works with the script.
I'm not sure what is going on, I'm quite new to Python so these error messages are barely comprehensible to me. Can anyone help with this?
Thank you ahead of time for any help.