i try to the hash-value for an image using imagehash with this code:
from PIL import Image
import imagehash
import requests
img = "https://cdn1.bitchesgirls.com/file/yael1c-yael-cohen-aug-31-2022/261656199427347453059782996929595436595.jpg"
# img = "https://i.imgur.com/5bGzZi7.jpg"
resp = requests.get(img, stream=True)
ihashImg = imagehash.average_hash(Image.open(resp.raw))
print(ihashImg)
When i try to run this code i get this error:
$ python test1.py
Traceback (most recent call last):
File "C:\Users\Polzi\Documents\DEV\Fiverr\TRY\pilom1\test1.py", line 7, in <module>
ihashImg = imagehash.average_hash(Image.open(resp.raw))
File "C:\Users\Polzi\Documents\DEV\.venv\test\lib\site-packages\PIL\Image.py", line 3147, in open
raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000002128FEA6860>
Why is this (for at least some pics) not working?
Eg. this picture works without problems: https://i.imgur.com/5bGzZi7.jpg