Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the type of return value of dhash.format_hex() is str #2

Closed
BBge opened this issue Dec 17, 2017 · 4 comments
Closed

the type of return value of dhash.format_hex() is str #2

BBge opened this issue Dec 17, 2017 · 4 comments

Comments

@BBge
Copy link

BBge commented Dec 17, 2017

the type of return value of dhash.format_hex() is str, maybe you can change the type of return value to hex. And the users needn't to convert it when they use dhash.get_num_bits_different().

@Runisco
Copy link

Runisco commented May 29, 2018

This is screwing me over. I'm finding no way to use get_num_bits with any form of variable that converts it to a hex number. With all the excuses in the book, no str, no int even when it's hex.
Only way is to manually enter hex numbers, and then this is rendered useless.

@benhoyt
Copy link
Owner

benhoyt commented May 29, 2018

Sorry, but I'm not really sure what you're asking. Most functions that convert to hex return a str in Python, for example the built-in hex() function. There's no such thing as a "hex type", at least not in the standard library.

If you want to use get_num_bits_different(), first call dhash_int() on both images (this returns an integer), then pass the results of those to get_num_bits_different(). For example, see here: https://github.com/Jetsetter/dhash/blob/master/dhash.py#L281-L283

@benhoyt benhoyt closed this as completed May 29, 2018
@Runisco
Copy link

Runisco commented May 29, 2018

image1 = Image.open('image_name.jpg')
hash1 = dhash_int(image1)

Traceback (most recent call last):
File "*", line 105, in
hash1 = dhash_int(image1)
NameError: name 'dhash_int' is not defined

@benhoyt
Copy link
Owner

benhoyt commented May 29, 2018

How are you importing dhash? If you're using import dhash then you'll have to type dhash.dhash_int() Otherwise you can do from dhash import dhash_int and then use it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants