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
impl ImageEncoderBuilder
Sourcepub fn width(self, w: u32) -> Self
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.
Sourcepub fn height(self, h: u32) -> Self
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.
Sourcepub fn quality(self, q: u32) -> Self
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
Sourcepub fn pixel_format(self, fmt: PixelFormat) -> Self
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.
Sourcepub fn build(self) -> Result<ImageEncoder, EncodeError>
pub fn build(self) -> Result<ImageEncoder, EncodeError>
Validate settings and return an ImageEncoder.
§Errors
EncodeError::InvalidConfig— path has no extension, or width/height is zeroEncodeError::UnsupportedCodec— extension is not a supported image format