Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Object has no attribute 'Read' Error: PIL Library

I am trying to load an image from a specific URL using the Image.Open() method from the PIL library, however I am getting the following error:

'Response' object has no attribute 'read'

My code is as follows:

image1 = Image.open(requests.get(URL))

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is addressed in the requests Quickstart:

from PIL import Image
from io import BytesIO

i = Image.open(BytesIO(r.content))

where r is a Response object such that r = requests.get(URL).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading