question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

imagehash.average_hash results in array instead of string

See original GitHub issue

Using python 2.7, when I try:

   `from PIL import Image 
   import imagehash
   img = Image.open(path)
   hash = imagehash.average_hash(img)
    print ("hash is:", hash)`

The result is an array like this:

('hash is:', array([[False, False, False, True, False, False, True, True], [False, False, False, True, True, True, True, True], [False, True, False, True, True, True, True, True], [False, True, True, True, True, True, True, True], [False, True, True, True, False, True, False, False], [False, True, True, True, True, True, True, False], [False, False, True, False, False, False, True, False], [False, False, False, False, False, False, True, True]])

Instead of a string. What I’m missing here? How can I fix it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
k0ficommented, Aug 22, 2019

This works fine on an stand-alone python file. But as I need to save hash to mysql database, so that the comparison can be done later. And there started the problem.

1reaction
step21commented, Aug 20, 2019

well if we look at https://github.com/JohannesBuchner/imagehash/blob/master/imagehash/__init__.py we find def hex_to_hash(hexstr) which takes a string and gives you a hash object. Then you should be able to compute the distance as normal, afaik.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Numpy error trying to use difference hashing with ...
I am trying to perform difference hashing with the python ImageHash library and keep getting a numpy error. The error ...
Read more >
Image hashing with OpenCV and Python - PyImageSearch
This tutorial covers how to perform image hashing and perceptual hashing using computer vision and image processing via OpenCV and Python.
Read more >
ImageHash - PyPI
An image hashing library written in Python. ImageHash supports: Average hashing. Perceptual hashing. Difference hashing. Wavelet hashing.
Read more >
Looks Like It - The Hacker Factor Blog
As with the Average Hash, pHash values can be compared using the same Hamming distance algorithm. (Just compare each bit position and count ......
Read more >
Hashing - Imagededup
image_array : Optional, used instead of image_file. Image typecast to numpy array. Returns. hash: A 16 character hexadecimal string hash for the image....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found