pub struct JxlEncoder<'prl, 'mm> {
pub has_alpha: bool,
pub lossless: Option<bool>,
pub speed: EncoderSpeed,
pub quality: f32,
pub use_container: bool,
pub uses_original_profile: bool,
pub decoding_speed: i64,
pub init_buffer_size: usize,
pub color_encoding: Option<ColorEncoding>,
pub target_intensity: Option<f32>,
pub parallel_runner: Option<&'prl dyn ParallelRunner>,
/* private fields */
}Expand description
JPEG XL Encoder
Fields§
§has_alpha: boolSet alpha channel
Default: false
lossless: Option<bool>Set lossless
Default: false
speed: EncoderSpeedSet speed
Default: Squirrel (7).
quality: f32Set quality for lossy compression: target max butteraugli distance, lower = higher quality
Range: 0 .. 15.
0.0 = mathematically lossless (however, use lossless to use true lossless).
1.0 = visually lossless.
Recommended range: 0.5 .. 3.0.
Default value: 1.0.
If lossless is set to true, this value is unused and implied to be 0.
use_container: boolConfigure the encoder to use the JPEG XL container format
Using the JPEG XL container format allows one to store metadata such as JPEG reconstruction; but it adds a few bytes to the encoded file for container headers even if there is no extra metadata.
uses_original_profile: boolConfigure the encoder to use the original color profile
If the input image has a color profile, it will be used for the encoded image. Otherwise, an internal fixed color profile is chosen (which should be smaller).
When lossless re-compressing JPEG image, you must set this to true.
Default: false
decoding_speed: i64Set the decoding speed tier
Minimum is 0 (highest quality), and maximum is 4 (lowest quality). Default is 0.
init_buffer_size: usizeSet initial output buffer size in bytes. Anything less than 32 bytes will be rounded up to 32 bytes.
Default: 512 KiB
color_encoding: Option<ColorEncoding>Set color encoding
Default: sRGB for int, Linear sRGB for float
target_intensity: Option<f32>Set HDR target intensity. Specify the target intensity in nits for 1.0 value
parallel_runner: Option<&'prl dyn ParallelRunner>Set parallel runner
Default: None, indicating single thread execution
Implementations§
Source§impl<'prl, 'mm> JxlEncoder<'prl, 'mm>
impl<'prl, 'mm> JxlEncoder<'prl, 'mm>
Sourcepub fn builder() -> JxlEncoderBuilder<'prl, 'mm>
pub fn builder() -> JxlEncoderBuilder<'prl, 'mm>
Build a JxlEncoder
§Errors
Return EncodeError::CannotCreateEncoder if it fails to create the encoder
Source§impl<'prl, 'mm> JxlEncoder<'prl, 'mm>
impl<'prl, 'mm> JxlEncoder<'prl, 'mm>
Sourcepub fn set_frame_option(
&mut self,
option: JxlEncoderFrameSettingId,
value: i64,
) -> Result<(), EncodeError>
pub fn set_frame_option( &mut self, option: JxlEncoderFrameSettingId, value: i64, ) -> Result<(), EncodeError>
Sourcepub fn multiple<'enc, U: PixelType>(
&'enc mut self,
width: u32,
height: u32,
) -> Result<MultiFrames<'enc, 'prl, 'mm, U>, EncodeError>
pub fn multiple<'enc, U: PixelType>( &'enc mut self, width: u32, height: u32, ) -> Result<MultiFrames<'enc, 'prl, 'mm, U>, EncodeError>
Return a wrapper type for adding multiple frames to the encoder
§Errors
Return EncodeError if it fails to set up the encoder
Sourcepub fn add_metadata(
&mut self,
metadata: &Metadata<'_>,
compress: bool,
) -> Result<(), EncodeError>
pub fn add_metadata( &mut self, metadata: &Metadata<'_>, compress: bool, ) -> Result<(), EncodeError>
Sourcepub fn encode_jpeg(
&mut self,
data: &[u8],
) -> Result<EncoderResult<u8>, EncodeError>
pub fn encode_jpeg( &mut self, data: &[u8], ) -> Result<EncoderResult<u8>, EncodeError>
Encode a JPEG XL image from existing raw JPEG data
Note: Only support output pixel type of u8. Ignore alpha channel settings
§Errors
Return EncodeError if the internal encoder fails to encode
Sourcepub fn encode<T: PixelType, U: PixelType>(
&mut self,
data: &[T],
width: u32,
height: u32,
) -> Result<EncoderResult<U>, EncodeError>
pub fn encode<T: PixelType, U: PixelType>( &mut self, data: &[T], width: u32, height: u32, ) -> Result<EncoderResult<U>, EncodeError>
Encode a JPEG XL image from pixels
Note: Use RGB(3) channels, native endianness and no alignment. Ignore alpha channel settings
§Errors
Return EncodeError if the internal encoder fails to encode
Sourcepub fn encode_frame<T: PixelType, U: PixelType>(
&mut self,
frame: &EncoderFrame<'_, T>,
width: u32,
height: u32,
) -> Result<EncoderResult<U>, EncodeError>
pub fn encode_frame<T: PixelType, U: PixelType>( &mut self, frame: &EncoderFrame<'_, T>, width: u32, height: u32, ) -> Result<EncoderResult<U>, EncodeError>
Encode a JPEG XL image from a frame.
See EncoderFrame for custom options of the original pixels.
§Errors
Return EncodeError if the internal encoder fails to encode