View Source ThumbHash (ThumbHash v0.2.0)

A bridge to the Rust ThumbHash library. See: https://github.com/evanw/thumbhash for original implementation.

Note: a Rust toolchain is required to compile the rust deps.

Summary

Functions

Generates a base64 encoded thumbhash of the image located at path

Generates a base64 encoded thumbhash of the image stored in thumbnail

Generates a base64-encoded, inline representation of an image from a base64-encoded hash in the given format (default: ".png")

Generates an image from a base64-encoded hash

Takes rgba data as a binary in u8 rgba format flattened with 4 values per pixel. e.g. <<r1 g1 b1 a1 r2 g2 b2 a2 ...>> Returns a list of integer values that make up a thumbhash of the image Images must be pre-scaled to fit within a 100px x 100px bounding box.

Takes a hash as a binary and returns the width, height, and image data.

Functions

Link to this function

generate_base64_hash!(path)

View Source
@spec generate_base64_hash!(Path.t()) :: binary() | no_return()

Generates a base64 encoded thumbhash of the image located at path

Link to this function

generate_base64_hash_from_binary!(buffer)

View Source
@spec generate_base64_hash_from_binary!(binary()) :: binary() | no_return()

Generates a base64 encoded thumbhash of the image stored in thumbnail

Link to this function

generate_base64_inline_image!(hash, format \\ ".png")

View Source
@spec generate_base64_inline_image!(binary(), binary()) :: binary() | no_return()

Generates a base64-encoded, inline representation of an image from a base64-encoded hash in the given format (default: ".png")

@spec generate_image!(binary()) :: Vix.Vips.Image.t() | no_return()

Generates an image from a base64-encoded hash

Link to this function

rgba_to_thumb_hash(width, height, rgba)

View Source
@spec rgba_to_thumb_hash(non_neg_integer(), non_neg_integer(), binary()) ::
  [byte()] | no_return()

Takes rgba data as a binary in u8 rgba format flattened with 4 values per pixel. e.g. <<r1 g1 b1 a1 r2 g2 b2 a2 ...>> Returns a list of integer values that make up a thumbhash of the image Images must be pre-scaled to fit within a 100px x 100px bounding box.

Link to this function

thumb_hash_to_rgba(b64_hash)

View Source
@spec thumb_hash_to_rgba([byte()]) ::
  {:ok, {non_neg_integer(), non_neg_integer(), binary()}}
  | {:error, any()}
  | no_return()

Takes a hash as a binary and returns the width, height, and image data.