This is browser image hash generator.
This library is made to generate the same hash as image-hash as much as possible.
- difference hashing (dHash)
$ npm install browser-image-hash
import {DifferenceHashBuilder, Hash} from 'browser-image-hash';
document.addEventListener('DOMContentLoaded', async () => {
const builder = new DifferenceHashBuilder();
const targetURL = new URL('./example.jpg', window.location.href);
const destHash = await builder.build(targetURL);
const srcHash = new Hash('0111011001110000011110010101101100110011000100110101101000111000');
if (srcHash.getHammingDistance(destHash) <= 10) {
console.log('Resembles');
return;
}
console.log('Different');
});