I am reading a jpg image from a URL from Facebook using the Python Requests library. When I compare the byte data recieved from the request against the byte data from reading the same image locally, I see significant differences. Here is the code I am using:
import requests
url = 'https://scontent.xx.fdcdn.net/...'
res = requests.get(url)
data = open('filepath.jpg', 'rb').read()
print(len(res.content), len(data))
Using this code, I would expect the lengths to be the same but I see a difference of nearly 1.7 million (with res.content being the larger one) which is crazy.
So I used PIL to save the image to a new file to test if the excess bits were causing a problem, but I got the same image.
Additionally, testing this with different URLs and images such as https://tinyjpg.com/images/social/website.jpg and the byte data was the exact same.
Any ideas as to why I would get such weird results from Facebook / my code? I've been troubleshooting for a while and nothing has come up.