Skip to main content

encode

Function encode 

Source
pub fn encode(
    image: &Image,
    mode: EncodeMode,
    metadata: Metadata,
) -> Result<Vec<u8>, CliError>
Expand description

Encode an Image into a complete WebP file — lossless or lossy per mode — embedding exactly the given metadata (an empty Metadata yields a bare VP8L/VP8 file).

Uses the bare-ImageRef Encoder::encode_ref path so the CLI’s per-field -metadata selection is honored precisely (the encoder’s metadata is embedded verbatim, with no policy-based inheritance from the image).

§Errors

CliError::Codec if the image is invalid (out-of-range dimensions or a buffer-length mismatch).