Code Monkey home page Code Monkey logo

image-hash's Introduction

Build Status codecov

Browser image hash

This is browser image hash generator.

This library is made to generate the same hash as image-hash as much as possible.

Supported.

  • difference hashing (dHash)

Feature Suuport.

  • average hashing (aHash)
  • perception hashing (pHash)
  • wavelet hashing (wHash)

Installation

$ npm install browser-image-hash

Basic Using

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');
});

โš ๏ธ Since this library uses canvas, please be careful of the same origin policy.

Allowing cross-origin use of images and canvas

image-hash's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar eleontev avatar ytetsuro avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

image-hash's Issues

test faild.

The test is currently being fail due to an update to the dependency package, so please make sure the test passes.

add example.

Create an example directory in the project root and create a simple example that uses this library.

The sample meets the following requirements.

  • Drag and drop images to upload them.
  • Output the value of the uploaded dhash as a string to DOM.
  • Allow the example code to be built with esbuild. (call esbuild by npx.)
  • The web server will document how to set up the server so that it can be validated by the built-in server, such as php -S or python -m or npx http-server.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.