0

I see that there are two ways to download images using python-reuqests.

  1. Uisng PIL as stated in docs (https://requests.readthedocs.io/en/master/user/quickstart/#binary-response-content):

    from PIL import Image
    from io import BytesIO
    i = Image.open(BytesIO(r.content))
    
  2. using streamed response content:

    r = requests.get(url, stream=True)
    with open(image_name, 'wb') as f:
        for chunk in r.iter_content():
            f.write(chunk)
    

Which is the recommended wya to download images however? both have its merits I suyppose, and I was wondering what is the optimal approach.