pub struct Encoder { /* private fields */ }Expand description
JPEG encoder.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn from_config(config: EncoderConfig) -> Self
pub fn from_config(config: EncoderConfig) -> Self
Creates an encoder from configuration.
Sourcepub fn pixel_format(self, format: PixelFormat) -> Self
pub fn pixel_format(self, format: PixelFormat) -> Self
Sets the pixel format.
Sourcepub fn subsampling(self, subsampling: Subsampling) -> Self
pub fn subsampling(self, subsampling: Subsampling) -> Self
Sets chroma subsampling.
Sourcepub fn use_xyb(self, enable: bool) -> Self
pub fn use_xyb(self, enable: bool) -> Self
Enables XYB-optimized encoding mode.
XYB mode encodes images using the perceptually-optimized XYB color space from JPEG XL. This provides better quality at the same file size compared to standard YCbCr encoding.
The implementation includes:
- Full sRGB → linear RGB → XYB color space conversion
- XYB value scaling for optimal quantization
- Embedded ICC profile for decoder color interpretation
- Blue channel subsampling (R:2×2, G:2×2, B:1×1)
- Separate XYB-optimized quant tables per component
The ICC profile allows any ICC-aware decoder (including djpegli, ImageMagick, and most image viewers) to correctly interpret the XYB values back to sRGB.
Note: Without ICC profile support in the decoder, images will display with incorrect colors. Use standard YCbCr mode for maximum compatibility.
Sourcepub fn restart_interval(self, interval: u16) -> Self
pub fn restart_interval(self, interval: u16) -> Self
Sets the restart interval.
Sourcepub fn optimize_huffman(self, enable: bool) -> Self
pub fn optimize_huffman(self, enable: bool) -> Self
Enables optimized Huffman tables.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more