Nostradamus Prophecy Machine

    fast-blurhash
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    fast-blurhash

    npm npm bundle size

    Fast & tiny Wolt BlurHash decoder implementation

    Demo

    Install

    npm install --save fast-blurhash

    API

    fast-blurhash provides a drop-in replacement for original blurhash.decode

    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

    import { decodeBlurHash } from 'fast-blurhash';
    
    const pixels = decodeBlurHash('LEHV6nWB2yk8pyo0adR*.7kCMdnj', 32, 32);
    
    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);

    Install

    npm i fast-blurhash

    DownloadsWeekly Downloads

    704

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    14.6 kB

    Total Files

    11

    Last publish

    Collaborators

    • mad_gooze