KilianB / JImageHash

Perceptual image hashing library used to match similar images
MIT License
397 stars 80 forks source link

Problems with equals method #46

Open mpeters-tha opened 3 years ago

mpeters-tha commented 3 years ago

Hello,

I have an issue, not really a bug but maybe an improvement. Here is the use case:

After investigation, I found it is because the following part in equals method: if (getClass() != obj.getClass()) return false; My Hash from step 1 is of class: com.github.kilianB.hashAlgorithms.DifferenceHash$DHash while the second one is of class: com.github.kilianB.hash.Hash.

I tried to cast the first one in (Hash) but it doesn't seems to view the object as it.

One way to solve this migh be to do something like this in equals method intead of using the .getClass(): if (!(obj instanceof Hash)) return false;

Cheers. Matt

KilianB commented 3 years ago

Thanks for the comment. Would you be willing to create a small pull request? Then I can take a look at it and see if the change would break other places.

mpeters-tha commented 3 years ago

Haha, I'm not devlopper, never done that, but I can try 👍

mpeters-tha commented 3 years ago

Hi again, Sorry I need some help here. I've installed github desktop on my PC, cloned the repo, created a branch, edited the Hash.java file and commited the change, but when I want to publish my branch, it says "It looks like you don't have write access to kilianb / JImageHash". Did I miss something ? Should I create a fork instead, as proposed by gitHub ?

KilianB commented 3 years ago

Yes exactly, this is how git works . You create a fork (your own working copy of the code), which you are free to modify in any way you like.

You then can make changes

git add . git commit -m "message" git push

And afterwards create a pull request (this can be done via the github ui). Due to this process no one is able to change the code of a repository without permission of the actual owner but since your version is also online everyone can just download your version and try it out as well as be able to see who made the changes afterwards.

mpeters-tha commented 3 years ago

Thanks. Done, Sorry for my newbeeness.