Storehouse.Image.BlurHash (Storehouse v0.2.0)

Copy Markdown View Source

BlurHash: an image's placeholder as a short string, 20 to 30 characters, for a page to decode into a blur (blurhash on npm, and ports in most languages). The same string as its reference implementation, from the image's pixels: Storehouse.Analyzer.BlurHash gives it from a stored file.

Summary

Functions

The BlurHash of an image of width × height pixels, given as RGB, eight bits a band, row by row, with x × y components (1 to 9 each): more is more detail, and a longer string. Most use 4 × 3.

Functions

encode(width, height, rgb, x, y)

@spec encode(pos_integer(), pos_integer(), binary(), 1..9, 1..9) :: String.t()

The BlurHash of an image of width × height pixels, given as RGB, eight bits a band, row by row, with x × y components (1 to 9 each): more is more detail, and a longer string. Most use 4 × 3.

iex> red = :binary.copy(<<255, 0, 0>>, 4)
iex> Storehouse.Image.BlurHash.encode(2, 2, red, 4, 3)
"L~TI:j|cfQ|c|c|cfQ|cfQfQfQfQ"