Socket
Socket
Sign inDemoInstall

browser-image-hash

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-image-hash

Image to dhash for Browser


Version published
Weekly downloads
51K
increased by2.08%
Maintainers
1
Weekly downloads
 
Created
Source

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.

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

Keywords

FAQs

Package last updated on 09 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc