How do I open an image from the internet in PIL?

前端 未结 6 1985
难免孤独
难免孤独 2020-12-13 02:44

I would like to find the dimensions of an image on the internet. I tried using

from PIL import Image
import urllib2 as urllib
fd = urllib.urlopen(\"http://a/         


        
6条回答
  •  天涯浪人
    2020-12-13 03:36

    Using Python requests:

    from PIL import Image
    from StringIO import StringIO
    import requests
    
    r = requests.get("http://a/b/c")
    im = Image.open(StringIO(r.content))
    im.size
    

提交回复
热议问题