Function ravif::encode_rgb[][src]

pub fn encode_rgb(
    buffer: Img<&[RGB8]>,
    config: &EncConfig
) -> Result<(Vec<u8>, usize), Box<dyn Error + Send + Sync>>
Expand description

Make a new AVIF image from RGB pixels

Make the Img for the buffer like this:

Img::new(&pixels_rgb[..], width, height)

If you have pixels as u8 slice, then first do:

use rgb::ComponentSlice;
let pixels_rgba = pixels_u8.as_rgb();

returns AVIF file, size of color metadata