1

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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

1 Answers1

1

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))
enzo
  • 9,861
  • 3
  • 15
  • 38
  • 1
    after replacing , response = requests.get(url, stream = True) it worked. by the way thanks it worked – Jagdish Pal Jun 24 '21 at 05:39
  • @JagdishPal Glad to help! If my answer helped you, you can accept it by clicking on the big checkmark to select it as the accepted answer, so people answering can focus on older questions which still don't have answers. – enzo Jun 24 '21 at 17:07