Skip to content

Instantly share code, notes, and snippets.

View tilmanmoser's full-sized avatar

Tilman Moser tilmanmoser

View GitHub Profile
@tilmanmoser
tilmanmoser / blurhashDataURL.ts
Created August 10, 2023 20:25 — forked from mattiaz9/blurhashDataURL.ts
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
}