https://github.com/achou11/ssb-blobs-blurhash
SSB secret stack plugin to generate a blurhash hash for a provided blob
https://github.com/achou11/ssb-blobs-blurhash
blobs blurhash secret-stack ssb
Last synced: 10 months ago
JSON representation
SSB secret stack plugin to generate a blurhash hash for a provided blob
- Host: GitHub
- URL: https://github.com/achou11/ssb-blobs-blurhash
- Owner: achou11
- License: mit
- Created: 2022-08-05T16:54:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-10T14:02:35.000Z (over 3 years ago)
- Last Synced: 2025-02-11T23:56:32.393Z (10 months ago)
- Topics: blobs, blurhash, secret-stack, ssb
- Language: JavaScript
- Homepage:
- Size: 192 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ssb-blobs-blurhash
> SSB secret stack plugin to generate a blurhash hash for a provided blob
## Install
`npm install ssb-blobs-blurhash`
## Usage
- Requires **Node 12** or higher
- Requires `ssb-blobs`
```diff
SecretStack({appKey: require('ssb-caps').shs})
+ .use(require('ssb-blobs'))
+ .use(require('ssb-blobs-blurhash'))
.call(null, config)
```
## API
### `ssb.blobsBlurhash.generate(blobId, opts, cb) (muxrpc "async")`
- `blobId: string`: ssb blob id
- `opts: { width: number, details }`: options to use for generation.
- `width` is the pixel width to resize your blob image to, for generating the hash. The smaller this number is, the quicker the algorithm will run, but with lower quality. The higher this number is, the higher the quality and the slower the algorithm will run.
- `details` is a boolean that determines whether to return the hash (if `false`) or an object `{hash, componentX, componentY}` (if `true`)
- `cb: (err: any, hash: string) => void`: callback that provides the hash generated by [blurhash](https://github.com/woltapp/blurhash)
```js
ssb.blobsBlurHash.generate('abc123', { width: 48 }, (err, hash) => {
if (err) throw err
console.log(`Blurhash result is ${hash}`)
})
```
## License
MIT