BlurHash v1.0.0 BlurHash View Source

Pure Elixir implementation of Blurhash algorithm with no additional dependencies.

Blurhash is an algorithm by Dag Ågren of Wolt that decodes an image to a very compact (~ 20-30 bytes) ASCII string representation, which can be then decoded into a blurred placeholder image. See the main repo (https://github.com/woltapp/blurhash) for the rationale and details.

This library supports only encoding.

More details on https://blurha.sh/

Link to this section Summary

Functions

Calculates the blur hash from the given pixels

Link to this section Types

Specs

components_x() :: integer()

Specs

components_y() :: integer()

Specs

hash() :: String.t()

Specs

height() :: integer()

Specs

pixels() :: [integer()]

Specs

width() :: integer()

Link to this section Functions

Link to this function

encode(pixels, width, height, components_y, components_x)

View Source (since 1.0.0)

Specs

encode(pixels(), width(), height(), components_y(), components_x()) :: hash()

Calculates the blur hash from the given pixels

Returns Blurhash string

Examples

iex> BlurHash.encode(pixels, 30, 30, 4, 3)
"LEHV6nWB2yk8pyo0adR*.7kCMdnj"