I am downloading images from an offline system (Google Photos) I can download the files and save them locally that works fine.
However what i am trying to do is download them and turn them into a PIL Image so that i can use them and not have to store them locally first.
Works fine to save a file
for media_item in media_items:
image_data_response = authed_session.get(media_item['baseUrl'] + "=w500-h250")
print(image_data_response)
with open(media_item['filename'], "wb") as my_file:
my_file.write(image_data_response.content)
print(media_item['id'], media_item['filename'])
attempt to create PIL Image
for media_item in media_items:
width = media_item['mediaMetadata']['width']
height = media_item['mediaMetadata']['height']
image_size = (500, 250) # Width, height
image_data_response = authed_session.get(media_item['baseUrl'] + "=w500-h250")
test = Image.frombytes(mode="RGBA", size=image_size, data=image_data_response.content, decoder_name="raw")
result.append(test)
My error
No matter what i try i keep getting
ValueError: not enough image data
I even tried giving PIL the original size of the image it didn’t help.