Skip to content

Instantly share code, notes, and snippets.

View koganas's full-sized avatar

Daniel Koganas koganas

View GitHub Profile
@koganas
koganas / blurhashDataURL.ts
Created March 15, 2024 08:03 — 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
}