[go: up one dir, main page]

Struct ravif::Encoder

source ·
pub struct Encoder { /* private fields */ }
Expand description

Encoder config builder

Implementations§

Builder methods

Start here

Quality 1..=100. Panics if out of range.

Quality for the alpha channel only. 1..=100. Panics if out of range.

1..=10. 1 = very very slow, but max compression. 10 = quick, but larger file sizes and lower quality.

Changes how color channels are stored in the image. The default is YCbCr.

Note that this is only internal detail for the AVIF file, and doesn’t change color space of inputs to encode functions.

Store color channels using 10-bit depth instead of the default 8-bit.

Configures rayon thread pool size. The default None is to use all threads in the default rayon thread pool.

Configure handling of color channels in transparent images

Once done with config, call one of the encode_* functions

Make a new AVIF image from RGBA pixels (non-premultiplied, alpha last)

Make the Img for the buffer like this:

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

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

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

If all pixels are opaque, alpha channel will be left out automatically.

It’s highly recommended to apply cleared_alpha first.

returns AVIF file, size of color metadata, size of alpha metadata overhead

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

If config.color_space is ColorSpace::YCbCr, then it takes 8-bit BT.709 color space.

Alpha always uses full range. Chroma subsampling is not supported, and it’s a bad idea for AVIF anyway.

returns AVIF file, size of color metadata, size of alpha metadata overhead

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.