@@ -86,7 +86,7 @@ pub struct JxlEncoder<'prl, 'mm> {
8686 pub quality : f32 ,
8787 /// Configure the encoder to use the JPEG XL container format
8888 ///
89- /// Using the JPEG XL container format allows to store metadata such as JPEG reconstruction;
89+ /// Using the JPEG XL container format allows one to store metadata such as JPEG reconstruction;
9090 /// but it adds a few bytes to the encoded file for container headers
9191 /// even if there is no extra metadata.
9292 pub use_container : bool ,
@@ -95,7 +95,7 @@ pub struct JxlEncoder<'prl, 'mm> {
9595 /// If the input image has a color profile, it will be used for the encoded image.
9696 /// Otherwise, an internal fixed color profile is chosen (which should be smaller).
9797 ///
98- /// When lossless recompressing JPEG image, you must set this to true.
98+ /// When lossless re-compressing JPEG image, you must set this to true.
9999 ///
100100 /// Default: `false`
101101 pub uses_original_profile : bool ,
@@ -111,9 +111,13 @@ pub struct JxlEncoder<'prl, 'mm> {
111111
112112 /// Set color encoding
113113 ///
114- /// Default: SRGB for uint , Linear SRGB for float
114+ /// Default: sRGB for int , Linear sRGB for float
115115 pub color_encoding : Option < ColorEncoding > ,
116116
117+ /// Set HDR target intensity.
118+ /// Specify the target intensity in nits for 1.0 value
119+ pub target_intensity : Option < f32 > ,
120+
117121 /// Set parallel runner
118122 ///
119123 /// Default: `None`, indicating single thread execution
@@ -145,6 +149,7 @@ impl<'prl, 'mm> JxlEncoder<'prl, 'mm> {
145149 #[ builder( default ) ] decoding_speed : i64 ,
146150 init_buffer_size : Option < usize > ,
147151 color_encoding : Option < ColorEncoding > ,
152+ target_intensity : Option < f32 > ,
148153 parallel_runner : Option < & ' prl dyn ParallelRunner > ,
149154 #[ builder( default ) ] use_box : bool ,
150155 ) -> Result < Self , EncodeError > {
@@ -173,6 +178,7 @@ impl<'prl, 'mm> JxlEncoder<'prl, 'mm> {
173178 decoding_speed,
174179 init_buffer_size : init_buffer_size. map_or ( 512 * 1024 , |v| if v < 32 { 32 } else { v } ) ,
175180 color_encoding,
181+ target_intensity,
176182 parallel_runner,
177183 use_box,
178184 memory_manager,
@@ -295,18 +301,21 @@ impl JxlEncoder<'_, '_> {
295301 basic_info. num_color_channels = 1 ;
296302 }
297303
304+ if let Some ( target_intensity) = self . target_intensity {
305+ basic_info. intensity_target = target_intensity;
306+ }
307+
298308 if let Some ( pr) = self . parallel_runner {
299309 pr. callback_basic_info ( & basic_info) ;
300310 }
301311
302312 self . check_enc_status ( unsafe { JxlEncoderSetBasicInfo ( self . enc , & raw const basic_info) } ) ?;
303313
304- if let Some ( color_encoding) = self . color_encoding {
314+ if let Some ( color_encoding) = & self . color_encoding {
305315 self . check_enc_status ( unsafe {
306316 JxlEncoderSetColorEncoding ( self . enc , & color_encoding. into ( ) )
307317 } ) ?;
308318 }
309-
310319 Ok ( ( ) )
311320 }
312321
0 commit comments