tiny-webp 0.1.1

Lossy WebP encoder in Rust with a cwebp-shaped command line
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! The checked-in quality table regenerates from its formula.

#[path = "../src/quantize.rs"]
mod quantize;

#[test]
fn the_quality_lookup_regenerates_from_the_cube_root_formula() {
    let generated = core::array::from_fn(|quality| {
        let quality = quality as f64 / 100.0;
        let linear = if quality < 0.75 {
            quality * 2.0 / 3.0
        } else {
            2.0 * quality - 1.0
        };
        (127.0 * (1.0 - linear.cbrt())).floor() as u8
    });
    assert_eq!(generated, quantize::Q_TO_INDEX);
}