Storehouse.Image.ThumbHash (Storehouse v0.2.0)

Copy Markdown View Source

ThumbHash: an image's placeholder in about 25 bytes, its colours, its proportions and its transparency, for a page to decode into a blur (thumbhash on npm, and ports in most languages). The same bytes as its reference implementation, from the image's pixels: Storehouse.Analyzer.ThumbHash gives them from a stored file.

Summary

Functions

The ThumbHash of an image of width × height pixels, at most 100 each, given as RGBA, eight bits a band, row by row.

Functions

encode(width, height, rgba)

@spec encode(pos_integer(), pos_integer(), binary()) :: binary()

The ThumbHash of an image of width × height pixels, at most 100 each, given as RGBA, eight bits a band, row by row.

iex> red = :binary.copy(<<255, 0, 0, 255>>, 4)
iex> Storehouse.Image.ThumbHash.encode(2, 2, red) |> Base.encode64()
"1fsrBwB4CIeIiIiHiIiICIiH6OAIDo4A"