Trying to read and image using python, error is:'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Viewed 36

Trying to grab an image from an https link and read it as binary but failed.

import requests
file=requests.get("https://i.ytimg.com/vi/dPARXQO8dkw/hqdefault.jpg").content
with open(file, 'rb') as f:
        contents = f.read()

codec is faling to decode giving following error:

utf-8' codec can't decode byte 0xff in position 0: invalid start byte
0 Answers
Related