Skip to content

Instantly share code, notes, and snippets.

View oleggrishechkin's full-sized avatar

Oleg Grishechkin oleggrishechkin

View GitHub Profile
@mattiaz9
mattiaz9 / blurhashDataURL.ts
Last active July 19, 2024 05:10
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
}