About Downloading Images to Memory

Use a combination of requests, BytesIO, and Pillow to download an image to memory for processing before saving:

1
2
3
4
5
6
7
from PIL import Image
from io import BytesIO
import requests
url = "https://aidas.bendoraitis.lt/images/django-tricks.png"
response = requests.get(url)
im = Image.open(BytesIO(response.content))
# im.show()

Tips and Tricks Programming Python 3 requests