Skip to main content

AvifEncoder

Struct AvifEncoder 

Source
pub struct AvifEncoder { /* private fields */ }
Expand description

Encodes images to AVIF still images.

8-bit RGB in, mapped to AV1 identity-matrix 4:4:4. By default the encode is lossless; AvifEncoder::with_qindex selects a lossy quantizer (base_q_idx, 1..=255). Use Encode via the EncodeImage<Rgb8> trait, taking a typed ImageRef. AvifEncoder::with_rotation_ccw / AvifEncoder::with_mirror add irot/imir display-orientation transforms.

Implementations§

Source§

impl AvifEncoder

Source

pub fn new() -> Self

Creates an encoder (lossless by default).

Source

pub fn with_qindex(self, qindex: u8) -> Self

Sets the AV1 quantizer (base_q_idx): 0 is lossless, 1..=255 is lossy intra (higher quantizes more aggressively for smaller files). Returns the updated encoder for chaining.

Source

pub fn with_rotation_ccw(self, quarter_turns: u8) -> Self

Adds an irot display rotation of quarter_turns × 90° applied anti-clockwise (the value is taken modulo 4, so 0 clears it). The stored pixels are unchanged — a reader rotates at display time — so this records e.g. a camera’s EXIF orientation without re-encoding. Returns the updated encoder for chaining.

Source

pub fn with_mirror(self, axis: u8) -> Self

Adds an imir display mirror: axis = 0 mirrors about a vertical axis (left↔right), 1 about a horizontal axis (top↔bottom). The stored pixels are unchanged. Returns the updated encoder for chaining.

Trait Implementations§

Source§

impl Clone for AvifEncoder

Source§

fn clone(&self) -> AvifEncoder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AvifEncoder

Source§

impl Debug for AvifEncoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AvifEncoder

Source§

fn default() -> AvifEncoder

Returns the “default value” for a type. Read more
Source§

impl EncodeImage<Rgb8> for AvifEncoder

Source§

fn encode_image( &self, image: ImageRef<'_, Rgb8>, out: &mut Vec<u8>, ) -> Result<usize>

Maps the RGB image to AV1 identity 4:4:4 planes and wraps the temporal unit in an AVIF file.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.