Skip to content

Instantly share code, notes, and snippets.

@mattiaz9
mattiaz9 / blurhashDataURL.ts
Last active May 10, 2024 06:36
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const pixels = decode(hash, 32, 32)
const dataURL = parsePixels(pixels, 32, 32)
return dataURL
}