blush
Types
Components size - both x and y should be an integer between 1 and 9 inclusive. Higher values produce “better” hash image, but the resulting blurhash string is longer. A good default would be something like 4x4.
pub type Components {
Components(x: Int, y: Int)
}
Constructors
-
Components(x: Int, y: Int)
pub type EncodingError {
InvalidComponentsSize(message: String)
InvalidImageSize(message: String)
InvalidPixelArraySize(message: String)
InvalidPixelValue(message: String)
}
Constructors
-
InvalidComponentsSize(message: String) -
InvalidImageSize(message: String) -
InvalidPixelArraySize(message: String) -
InvalidPixelValue(message: String)
Data representation of an image - width and height cannot be zero or negeative. Pixels is a list of values from 0 to 255 inclusive. Each pixel is represented by 3 values in this order: [r, g, b].
For example - an image that’s 320x240 pixels should contain 320x240x3 = 230400 values.
pub type ImageData {
ImageData(width: Int, height: Int, pixels: List(Int))
}
Constructors
-
ImageData(width: Int, height: Int, pixels: List(Int))
Values
pub fn encode(
image: ImageData,
components: Components,
) -> Result(String, EncodingError)
Encodes the provided image into a BlurHash - that can be later decoded into thumbnail image or used with other BlurHash-compatible libraries.