Crate blurhash

source ·
Expand description

A pure Rust implementation of woltapp/blurhash.

§Encoding

use blurhash::encode;
use image::{GenericImageView, EncodableLayout};

let img = image::open("data/octocat.png").unwrap();
let (width, height) = img.dimensions();
let blurhash = encode(4, 3, width, height, img.to_rgba8().as_bytes()).unwrap();

assert_eq!(blurhash, "LNAdAqj[00aymkj[TKay9}ay-Sj[");

§Decoding

use blurhash::decode;

let pixels = decode("LBAdAqof00WCqZj[PDay0.WB}pof", 50, 50, 1.0);

Enums§

Functions§

  • Decodes the given blurhash to an image of the specified size.
  • Decodes the given blurhash to an image of the specified size into an existing buffer.
  • Calculates the blurhash for an image using the given x and y component counts.