0

I am passing url of an image to get its size (height and width) but it seems python is not able to fetch this url. I am using python 3.5

The actual code is:-

from urllib.request import urlopen
from PIL import Image

url = 'https://zdnet3.cbsistatic.com/hub/i/r/2014/12/01/f7247ce5-7921-11e4-b569-d4ae52e95e57/thumbnail/70x53/a5599f31ffa560131f54bcf8442e80ba/zd-defaultimage-news.jpg'
img = Image.open(urlopen(url))

print("Image size:", img.size)

I got this error:

"OSError: cannot identify image file <_io.BytesIO object at 0x000002907E898308>"

Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49

0 Answers0