Skip to main content

optimize

Function optimize 

Source
pub fn optimize(
    source: &[u8],
    target: ResizeTarget,
    quality: u8,
    preferred_format: FormatPreference,
    generate_blur: bool,
) -> Result<OptimizeResult, OptimizeError>
Expand description

Decodes source once, resizes it per target for the main result - preferred_format (the caller decides this from the request’s own Accept header) when that format’s own encoder succeeds, JPEG otherwise - and, when generate_blur is set, also produces a tiny blurred-placeholder thumbnail from the same decode (always JPEG, regardless of preferred_format - it’s consumed directly by the browser’s own CSS decoder as an inline data URI, never served as a standalone resource a format negotiation could apply to).