17,082
stars
+-5+-5+0
377
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions
README
BlurHash BlurHash is a compact representation of a placeholder for an image. Why would you want this? Does your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the images have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail images into your data to show as placeholders? BlurHash will solve your problems! How? Like this: You can also see nice examples and try it out yourself at blurha.sh! How does it work? In short, BlurHash takes an image, and gives you a short string (only 20-30 characters!) that represents the placeholder for this image. You do this on the backend of your service, and store the string along with the image. When you send data to your client, you send both the URL to the image, and the BlurHash string. Your client then takes the string, and decodes it into an image that it shows while the real image is loading over the network. The string is short enough that it comfortably fits into whatever data format you use. For instance, it can easily be added as a field in a JSON object. In summary: Want to know all the gory technical details? Read the algorithm description. Implementing the algorithm is actually quite easy! Implementations are short and easily ported to your favourite language or platform. Implementations So far, we have created these implementations: C - An encoder implementation in portable C code. Swift - Encoder and decoder implementations, and a larger library offering advanced features. There is also an example app to play around with the algorithm. Kotlin - A decoder implementation for Android. TypeScript - Encoder and decoder implementations, and an example page to test. Python - Integration of the C encoder code into Python. These cover our use cases, but could probably use polishing, extending and improving. There are also these third party implementations that we know of: Pure Python - Implementation of both the encoder and decoder in pure Python. One version in Go, and another version in Go. PHP - Encoder and decoder implementations in pure PHP. Java - Encoder implementation in Java. Clojure - Encoder and decoder implementations in Clojure. Nim - Encoder and decoder implementation in pure Nim. Rust and WebAssembly - Encoder and decoder implementations in Rust. Distributed as both native Rust and WebAssembly packages. Ruby - Encoder implementation in Ruby. Crystal - Encoder implementation in pure Crystal. Elm - Encoder and decoder in Elm. Dart - Encoder and decoder implementation in C into Dart using dart-ffi. Pure Dart - Encoder and decoder implementation in pure Dart. .NET - Encoder and decoder in C. JavaScript - Encoder and decoder implementation in pure JavaScript. .NET - Encoder implementation in C. Haskell - Encoder and decoder in pure Haskell. Scala - Encoder and decoder in Scala. Elixir - Encoder implementation in pu