pub struct LossyConfig { /* private fields */ }Expand description
Lossy (VarDCT) encoding configuration.
No Default — distance/quality is a required choice.
Implementations§
Source§impl LossyConfig
impl LossyConfig
Sourcepub fn from_quality(quality: Quality) -> Result<Self, EncodeError>
pub fn from_quality(quality: Quality) -> Result<Self, EncodeError>
Create from a Quality specification.
Sourcepub fn with_effort(self, effort: u8) -> Self
pub fn with_effort(self, effort: u8) -> Self
Set effort level (1–10).
Also adjusts butteraugli iterations to match libjxl’s effort gating,
unless with_butteraugli_iters was called explicitly.
Sourcepub fn with_gaborish(self, enable: bool) -> Self
pub fn with_gaborish(self, enable: bool) -> Self
Enable/disable gaborish inverse pre-filter (default: true).
Sourcepub fn with_noise(self, enable: bool) -> Self
pub fn with_noise(self, enable: bool) -> Self
Enable/disable noise synthesis (default: false).
Sourcepub fn with_denoise(self, enable: bool) -> Self
pub fn with_denoise(self, enable: bool) -> Self
Enable/disable Wiener denoising pre-filter (default: false). Implies noise.
Sourcepub fn with_error_diffusion(self, enable: bool) -> Self
pub fn with_error_diffusion(self, enable: bool) -> Self
Enable/disable error diffusion in AC quantization (default: true).
Sourcepub fn with_pixel_domain_loss(self, enable: bool) -> Self
pub fn with_pixel_domain_loss(self, enable: bool) -> Self
Enable/disable pixel-domain loss in strategy selection (default: true).
Sourcepub fn with_lz77(self, enable: bool) -> Self
pub fn with_lz77(self, enable: bool) -> Self
Enable/disable LZ77 backward references (default: false).
Sourcepub fn with_lz77_method(self, method: Lz77Method) -> Self
pub fn with_lz77_method(self, method: Lz77Method) -> Self
Set LZ77 method (default: Greedy).
Sourcepub fn with_force_strategy(self, strategy: Option<u8>) -> Self
pub fn with_force_strategy(self, strategy: Option<u8>) -> Self
Force a specific AC strategy for all blocks. None for auto-selection.
Sourcepub fn with_butteraugli_iters(self, n: u32) -> Self
pub fn with_butteraugli_iters(self, n: u32) -> Self
Set butteraugli quantization loop iterations explicitly.
Overrides the automatic effort-based default (effort 7: 0, effort 8: 2, effort 9+: 4).
Requires the butteraugli-loop feature.
Sourcepub fn error_diffusion(&self) -> bool
pub fn error_diffusion(&self) -> bool
Whether error diffusion in AC quantization is enabled.
Sourcepub fn pixel_domain_loss(&self) -> bool
pub fn pixel_domain_loss(&self) -> bool
Whether pixel-domain loss is enabled.
Sourcepub fn lz77_method(&self) -> Lz77Method
pub fn lz77_method(&self) -> Lz77Method
Current LZ77 method.
Sourcepub fn force_strategy(&self) -> Option<u8>
pub fn force_strategy(&self) -> Option<u8>
Forced AC strategy, if any.
Sourcepub fn butteraugli_iters(&self) -> u32
pub fn butteraugli_iters(&self) -> u32
Butteraugli quantization loop iterations.
Sourcepub fn encode_request(
&self,
width: u32,
height: u32,
layout: PixelLayout,
) -> EncodeRequest<'_>
pub fn encode_request( &self, width: u32, height: u32, layout: PixelLayout, ) -> EncodeRequest<'_>
Create an encode request for an image with this config.
Use this when you need to attach metadata, limits, or cancellation.
Sourcepub fn encode(
&self,
pixels: &[u8],
width: u32,
height: u32,
layout: PixelLayout,
) -> Result<Vec<u8>>
pub fn encode( &self, pixels: &[u8], width: u32, height: u32, layout: PixelLayout, ) -> Result<Vec<u8>>
Encode pixels directly with this config. Shortcut for simple cases.
let jxl = jxl_encoder::LossyConfig::new(1.0)
.encode(&pixels, 100, 100, jxl_encoder::PixelLayout::Rgb8)?;Sourcepub fn encode_into(
&self,
pixels: &[u8],
width: u32,
height: u32,
layout: PixelLayout,
out: &mut Vec<u8>,
) -> Result<()>
pub fn encode_into( &self, pixels: &[u8], width: u32, height: u32, layout: PixelLayout, out: &mut Vec<u8>, ) -> Result<()>
Encode pixels, appending to an existing buffer.
Sourcepub fn encode_animation(
&self,
width: u32,
height: u32,
layout: PixelLayout,
animation: &AnimationParams,
frames: &[AnimationFrame<'_>],
) -> Result<Vec<u8>>
pub fn encode_animation( &self, width: u32, height: u32, layout: PixelLayout, animation: &AnimationParams, frames: &[AnimationFrame<'_>], ) -> Result<Vec<u8>>
Encode a multi-frame animation as a lossy JXL.
Each frame must have the same dimensions and pixel layout. Returns the complete JXL codestream bytes.
Trait Implementations§
Source§impl Clone for LossyConfig
impl Clone for LossyConfig
Source§fn clone(&self) -> LossyConfig
fn clone(&self) -> LossyConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more