I have a script that steps through all of the images in the standard Camera Roll asset collection.
My loop to step through the Camera Roll album works just fine, however, there are some images that raise an AttributeError exception on a.get_image().
Code (I removed the asset-by-asset loop to concentrate on this one problem image):
a = album.assets[-2] #Image causing problem (-1 image works just fine).
try:
p = a.get_image()
except AttributeError as e:
print ('Attribute Error: {}'.format(e))
The variable 'a' seems to be just fine. It has a media_type of 'image', it has a modification_date, a location tuple, pixel height and width all of which seem fine.
The file opens just fine using Asset.get_ui_image(), but that is not what I want, and it would be great to figure out why this image which seems just like every other image in the Camera Roll, and whose asset object also seems fine, would have an issue.
The exception error variable, 'e', offers nothing more than the string: 'NoneType' object has no attribute 'decode'.
It seems as if the Asset.get_image() method attempts to use PIL.image.open() and something fails, but no real indicator (not sure what the exception string really means).
Any insights into figuring this out will be most welcome.
Thanks! B.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Update
I copied the offending photo from my iOS device to a Windows machine. I then wrote a Python script opening the picture file directly using PIL.Image.open(). Everything worked fine, no errors, and the EXIF information matched what is on the iOS device.
I want to attempt this on my iOS device. I have the filename, but do not know the path to the photo's directory, as such, I am getting a file not found error.
Does anyone know the iOS path to photos?
Thanks again, B.
For anyone interested, the issue has to do with the new Apple photo file format, HEIC.
Every file that I have with the HEIC extension fails.
I don't know the status of PIL and this new format. For the search "pythonista pil heic", each hit came back without a reference to HEIC. My guess is PIL is not yet ready for HEIC.
I did find this link, so others have seen this: Converting to JPEG given image data and UTI
If anyone knows the status of PIL and HEIC, it would be great to hear.
Thanks, B.