https://github.com/linusu/blockhash-core
Core implementation of the blockhash perceptual image hashing algorithm
https://github.com/linusu/blockhash-core
Last synced: about 1 year ago
JSON representation
Core implementation of the blockhash perceptual image hashing algorithm
- Host: GitHub
- URL: https://github.com/linusu/blockhash-core
- Owner: LinusU
- License: mit
- Created: 2019-12-07T13:14:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T14:27:28.000Z (almost 4 years ago)
- Last Synced: 2025-05-05T03:39:01.344Z (about 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 16
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Blockhash Core
This is the core implementation of the [blockhash perceptual image hashing algorithm](https://web.archive.org/web/20210827144701/http://blockhash.io).
Look at the main [`blockhash` package](https://github.com/commonsmachinery/blockhash-js) if you want a higher level api.
## Installation
```sh
npm install --save blockhash-core
```
## Usage
```js
const { bmvbhash } = require('blockhash-core')
const image = new ImageData(/* ... */)
const result = bmvbhash(image, 16)
console.log(result)
//=> f81bf99ffb803400e07f8c5d849f049707033a033fe33fe1bfe00e618ee30ca7
```
## API
### `bmvbhash(data, bits)`
- `data` ([`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData), required) - The input image data
- `bits` (`number`, required) - Create hash of size N^2 bits
- returns `string` - The resulting hash in hex format
Precise but slower, non-overlapping blocks.
This method is recommended as a good tradeoff between speed and good matches on any image size.
### `bmvbhashEven(data, bits)`
- `data` ([`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData), required) - The input image data
- `bits` (`number`, required) - Create hash of size N^2 bits
- returns `string` - The resulting hash in hex format
Quick and crude, non-overlapping blocks.
This method is only advisable when the image width and height are an even multiple of the number of blocks used.