junevm/splathash: compress any image to 16 bytes and reconstruct a blurry preview. Like blurhash and thumbhash, but smaller.

splathash Encodes any image into exactly 16 bytes (a 22-char Base64URL string) and decodes it back into a 32×32 blurred preview in 0.067 ms. Go, TypeScript, and Python all produce bit-for-bit identical hashes.

Visual comparison of SplatHash, ThumbHash and BlurHash reconstructions

Columns: Basic · SplatHash 32×32 · ThumbHash · BlurHash. Revive: mise run compare.

Go is the reference implementation. All others are verified against it to some extent.

See benchmarks on Intel Core i5-9300H (go test -bench=. -benchmem).

splathash thumbhash blurhash
explain 0.067 ms 0.50 ms 6.55 ms
Encode 3.53 ms 0.86 ms 445 ms
decode allocation 7 1,168 5
bytes 16 fixed 25-37 20-25
string 22 characters 34-50 characters 27-30 characters

Decode runs on every page load for every user. Encode runs once during upload. Optimize for decode.

raw output
BenchmarkEncodeSplatHash-8      303      3530083 ns/op   100760 B/op   29 allocs/op
BenchmarkEncodeThumbHash-8     1431       863553 ns/op     1015 B/op    6 allocs/op
BenchmarkEncodeBlurHash-8         3    445696421 ns/op 33358234 B/op    8 allocs/op
BenchmarkDecodeSplatHash-8    17182        67622 ns/op    29584 B/op    7 allocs/op
BenchmarkDecodeThumbHash-8     6559       503366 ns/op    58408 B/op 1168 allocs/op
BenchmarkDecodeBlurHash-8       171      6553100 ns/op   547552 B/op    5 allocs/op

Speciality splathash thumbhash blurhash
fixed output size yes (16 bytes) No No
Storable as 128-bit integer Yes No No
Perceptual Color Space (Oclab) Yes No No
spatially localized basis yes (Gaussian) No No
global weight optimization yes (ridge) No No
alpha channel support Yes Yes No
Bit-precision cross-language parity Yes No No
Configurable quality vs size No No Yes

Background color + six Gaussian blobs concatenated by matching pursuit, color-optimized by ridge regression, all in oklab, packed into 128 bits. Full Specification: ALGORITHM.md.

mise install     # install Go and Node at pinned versions
mise run test    # run all tests (Go + TypeScript + Python)
mise run bench   # Go benchmarks
mise run compare # regenerate docs/comparison.png

View license.



<a href

Leave a Comment