Skip to main content

ImageEncoderBuilder

Struct ImageEncoderBuilder 

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

Builder for ImageEncoder.

Created via ImageEncoder::create or ImageEncoder::new. Extension validation and zero-dimension checks happen in build.

Implementations§

Source§

impl ImageEncoderBuilder

Source

pub fn width(self, w: u32) -> Self

Override the output width in pixels.

If not set, the source frame’s width is used. If only width is set (without height), the source frame’s height is preserved unchanged.

Source

pub fn height(self, h: u32) -> Self

Override the output height in pixels.

If not set, the source frame’s height is used. If only height is set (without width), the source frame’s width is preserved unchanged.

Source

pub fn quality(self, q: u32) -> Self

Set encoder quality on a 0–100 scale (100 = best quality).

The value is mapped per codec:

  • JPEG: qscale 1–31 (100 → 1 = best, 0 → 31 = worst)
  • PNG: compression level 0–9 (100 → 9 = maximum compression)
  • WebP: quality 0–100 (direct mapping)
  • BMP / TIFF: no quality concept; the value is ignored with a warning
Source

pub fn pixel_format(self, fmt: PixelFormat) -> Self

Override the output pixel format.

If not set, a codec-native default is used (e.g. YUVJ420P for JPEG, RGB24 for PNG). Setting an incompatible format may cause encoding to fail with an FFmpeg error.

Source

pub fn build(self) -> Result<ImageEncoder, EncodeError>

Validate settings and return an ImageEncoder.

§Errors

Trait Implementations§

Source§

impl Debug for ImageEncoderBuilder

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.