New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fast-blurhash

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-blurhash

Fast and tiny js decoder for the Wolt BlurHash algorithm

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21K
decreased by-9.41%
Maintainers
0
Weekly downloads
 
Created
Source

fast-blurhash

npm npm bundle size

Fast & tiny Wolt BlurHash decoder implementation

Demo

Install

npm install --save fast-blurhash

API

decodeBlurHash

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';

// 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);

getBlurHashAverageColor

getBlurHashAverageColor(blurhash: string) => [number, number, number]`

getBlurHashAverageColor returns an average color of a passed blurhash image in [red, green, blue].

Example
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(',')})';

Keywords

FAQs

Package last updated on 02 Aug 2024

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