HOME/Articles/

pil example image with requests (snippet)

Article Outline

Python pil example 'image with requests'

Modules used in program:

  • import numpy as np
  • import requests

python image with requests

Python pil example: image with requests

import requests
from PIL import Image
from io import BytesIO
import numpy as np

res = requests.get(image_url)
image = Image.open(BytesIO(res.content))
image_array = np.array(image)