Skip to main content

encode_with_auto_quality

Function encode_with_auto_quality 

Source
pub fn encode_with_auto_quality(
    original: &DynamicImage,
    cfg: &ProcessConfig,
    target_ssim: f64,
    min_q: u8,
    max_q: u8,
) -> Result<(Vec<u8>, u8), String>
Expand description

Binary-search the lowest quality in [min_q, max_q] that meets a given SSIM target against the original. Returns the encoded bytes and the quality used.

Used when callers want “automatic” quality: pick the smallest file that still passes a perceptual threshold (typically 0.95).