1

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))
0

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.