Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-image-hash

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-image-hash

Perceptual image hash for node.js

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
154
increased by40%
Maintainers
1
Weekly downloads
 
Created
Source

node-image-hash npm version

Perceptual image hash for node.js

Installation

npm install node-image-hash

Basic usage

const imageHash = require('node-image-hash');

imageHash
  .hash('buffer/or/path/to/file/', 8, 'hex')
  .then((hash) => {
    console.log(hash.hash); // '83c3d381c38985a5'
    console.log(hash.type); // 'blockhash8'
  });

API

.hash(filepath[, bits][, format])

Returns: ES6 Promise, resolved returns hash string in specified format and length (e.g. 83c3d381c38985a5)

Parameters:

  • filepath - path to the image, or Buffer
  • bits (optional) - hash length [default: 64]
  • format (optional) - output format [default: hex] (Available: hex, latin1, base64, binary)
.syncHash(filepath[, bits][, format])

By default, .hash generates new node.js processes to calculate the hash. .syncHash will calculate the hash in the same node.js process (About 2.3x times slower, depending on your CPU)

.close()

Close all underlying workers. If you use the asynchronous hashing algorithm, you need to call this at the end of your program to close all currently open workers. Otherwise, your program may keep running until manually interrupted.

Keywords

FAQs

Package last updated on 10 Apr 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