Is there any way by which I can apply imagehash function in online images in Python

374 Views Asked by At

I want to get fingerprints for images with the help of the imagehash function in Python but in order to apply

hash = imagehash.average_hash(Image.open(path))

the image needs to be in storage. Is there any way from which by just giving the image URL I can get the fingerprint of the image?

1

There are 1 best solutions below

2
On BEST ANSWER

You can use requests:

url = 'https://commons.wikimedia.org/wiki/File:Example.png'

import requests
response = requests.get(url, stream=True)
ihash = imagehash.average_hash(Image.open(response.raw))