Fast and tiny js decoder for the Wolt BlurHash algorithm
npm install fast-blurhash

> Fast & tiny Wolt BlurHash decoder implementation
- š¤ Tiny: ā1kb minified
- š Fast: up to 70% faster then original blurhash.decode (see benchmark)
``sh`
npm install --save fast-blurhash
fast-blurhash provides a drop-in replacement for original blurhash.decode
`typescript
decodeBlurHash(blurhash: string, width: number, height: number, punch?: number) => Uint8ClampedArray
``
decodeBlurHash uses approximate calculation for speed reasons. Results may slightly differ from original blurhash.decode but the diff is not noticeable (see tests).
ā ļø decodeBlurHash does not validate input.
#### Example
`js
import { decodeBlurHash } from 'fast-blurhash';
// decode blurHash image
const pixels = decodeBlurHash('LEHV6nWB2yk8pyo0adR*.7kCMdnj', 32, 32);
// draw it on canvas
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const imageData = ctx.createImageData(width, height);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
document.body.append(canvas);
`
`typescript
getBlurHashAverageColor(blurhash: string) => [number, number, number]
``
getBlurHashAverageColor returns an average color of a passed blurhash image in [red, green, blue].
#### Example
`js
import { getBlurHashAverageColor } from 'fast-blurhash';
// get image average color and use it as css background color
const rgbAverageColor = getBlurHashAverageColor('LEHV6nWB2yk8pyo0adR*.7kCMdnj');
document.body.style.backgroundColor = rgb(${rgbAverageColor.join(',')})';
```