### Exif::build Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/enum.Exif.html Starts building EXIF metadata from common fields. ```APIDOC ## pub fn build() -> ExifFields ### Description Initializes an ExifFields builder to construct EXIF metadata from common fields. This builder supports chaining methods like .orientation() and .copyright(). ### Returns - **ExifFields** - A builder object for constructing EXIF metadata. ``` -------------------------------- ### DecodeRequest Usage Example Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeRequest.html Demonstrates how to perform full-buffer and streaming decodes using a DecodePool and a cancellation token. ```rust use zenjpeg::decode::{Decoder, DecodePool}; let decoder = Decoder::new(); let pool = DecodePool::new(); // Full-buffer decode with pool let result = decoder.request(&jpeg_data) .pool(&pool) .stop(&cancel_token) .decode()?; // Streaming decode with pool let reader = decoder.request(&jpeg_data) .pool(&pool) .scanline_reader()?; ``` -------------------------------- ### Example Implementation Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/trait.Stop.html A custom implementation of the Stop trait using an AtomicBool to signal cancellation. ```rust use enough::{Stop, StopReason}; use core::sync::atomic::{AtomicBool, Ordering}; pub struct MyStop<'a> { cancelled: &'a AtomicBool, } impl Stop for MyStop<'_> { fn check(&self) -> Result<(), StopReason> { if self.cancelled.load(Ordering::Relaxed) { Err(StopReason::Cancelled) } else { Ok(()) } } } ``` -------------------------------- ### Configure Encoder Options Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/index.html Examples of configuring YCbCr, XYB, and Grayscale modes, including quality settings. ```rust // YCbCr mode (standard JPEG - most compatible) let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .progressive(true) // Progressive JPEG (~3% smaller) .sharp_yuv(true) // Better color edges (~3x slower) .icc_profile(bytes); // Attach ICC profile // XYB mode (perceptual color space - better quality) let config = EncoderConfig::xyb(85, XybSubsampling::BQuarter) .progressive(true); // Grayscale mode let config = EncoderConfig::grayscale(85); // Quality can also use enum variants: let config = EncoderConfig::ycbcr(Quality::ApproxSsim2(90.0), ChromaSubsampling::None); let config = EncoderConfig::ycbcr(Quality::ApproxButteraugli(1.0), ChromaSubsampling::Quarter); ``` -------------------------------- ### Initialize EncoderConfig with custom tables Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Example of initializing an EncoderConfig instance with specific quality and subsampling settings, including custom quantization tables. ```rust let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .tables(Box::new(tables)); ``` -------------------------------- ### Decode JPEG Quick Start Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/index.html Basic usage of the Decoder to process image data. ```rust use zenjpeg::decoder::{Decoder, DecodeResult, Result}; fn decode_jpeg(data: &[u8]) -> Result { Decoder::new().decode(data, enough::Unstoppable) } ``` -------------------------------- ### Get Recommended Quality and Subsampling Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/detect/struct.JpegProbe.html Uses the probe to determine the recommended quality and subsampling settings for re-encoding. ```rust let probe = zenjpeg::detect::probe(&source_jpeg)?; let config = EncoderConfig::ycbcr( probe.recommended_quality(), probe.recommended_subsampling(), ).auto_optimize(true); ``` -------------------------------- ### Configure Limits with builder methods Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.Limits.html Example of using the builder pattern to set specific resource constraints on a Limits instance. ```rust use zenjpeg::encoder::Limits; let limits = Limits::default() .max_pixels(100_000_000) // 100 megapixels .max_memory(512 * 1024 * 1024) // 512 MB .max_output(50 * 1024 * 1024); // 50 MB output ``` -------------------------------- ### Access decoded coefficients Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodedCoefficients.html Example showing how to decode JPEG data and access specific DCT coefficients. ```rust use zenjpeg::decode::Decoder; let decoder = Decoder::new(); let coeffs = decoder.decode_coefficients(&jpeg_data)?; // Access Y component DC coefficient for first block let y_dc = coeffs.components[0].block(0)[0]; println!("Y DC: {}", y_dc); ``` -------------------------------- ### Handle DecodeWarnings Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/enum.DecodeWarning.html Example of iterating through collected warnings after a decoding operation. ```rust use zenjpeg::decoder::{Decoder, DecodeWarning}; let result = Decoder::new().decode(&data, enough::Unstoppable)?; for warning in result.warnings() { match warning { DecodeWarning::MissingHuffmanTables => eprintln!("MJPEG: used standard tables"), DecodeWarning::TruncatedScan { .. } => eprintln!("Scan data was truncated"), _ => {} } } ``` -------------------------------- ### Pixel Implementations Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/trait.Pixel.html Examples of Pixel trait implementations for various pixel types and their corresponding layouts. ```rust impl Pixel for Bgr { const LAYOUT: PixelLayout = PixelLayout::Bgr8Srgb } ``` ```rust impl Pixel for Bgra { const LAYOUT: PixelLayout = PixelLayout::Bgra8Srgb } ``` ```rust impl Pixel for Gray { const LAYOUT: PixelLayout = PixelLayout::GrayF32Linear } ``` ```rust impl Pixel for Gray { const LAYOUT: PixelLayout = PixelLayout::Gray8Srgb } ``` ```rust impl Pixel for Gray { const LAYOUT: PixelLayout = PixelLayout::Gray16Linear } ``` ```rust impl Pixel for RGB { const LAYOUT: PixelLayout = PixelLayout::RgbF32Linear } ``` ```rust impl Pixel for RGB { const LAYOUT: PixelLayout = PixelLayout::Rgb8Srgb } ``` ```rust impl Pixel for RGB { const LAYOUT: PixelLayout = PixelLayout::Rgb16Linear } ``` ```rust impl Pixel for RGBA { const LAYOUT: PixelLayout = PixelLayout::RgbaF32Linear } ``` ```rust impl Pixel for RGBA { const LAYOUT: PixelLayout = PixelLayout::Rgba8Srgb } ``` ```rust impl Pixel for RGBA { const LAYOUT: PixelLayout = PixelLayout::Rgba16Linear } ``` -------------------------------- ### Conditional Result Checking Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Example of using is_ok_and to check a Result against a predicate. ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### Cloning Result Contents Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Examples of using .cloned() on Result types containing references. ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` -------------------------------- ### Flattening Nested Results Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Examples of flattening nested Result types. ```rust let x: Result, u32> = Ok(Ok("hello")); assert_eq!(Ok("hello"), x.flatten()); let x: Result, u32> = Ok(Err(6)); assert_eq!(Err(6), x.flatten()); let x: Result, u32> = Err(6); assert_eq!(Err(6), x.flatten()); ``` ```rust let x: Result, u32>, u32> = Ok(Ok(Ok("hello"))); assert_eq!(Ok(Ok("hello")), x.flatten()); assert_eq!(Ok("hello"), x.flatten().flatten()); ``` -------------------------------- ### Unwrap Unchecked Examples Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/type.EncodeResult.html Demonstrates usage of unwrap_unchecked and unwrap_err_unchecked, noting that calling these on the wrong variant is undefined behavior. ```rust let x: Result = Ok(2); assert_eq!(unsafe { x.unwrap_unchecked() }, 2); ``` ```rust let x: Result = Err("emergency failure"); unsafe { x.unwrap_unchecked() }; // Undefined behavior! ``` ```rust let x: Result = Ok(2); unsafe { x.unwrap_err_unchecked() }; // Undefined behavior! ``` ```rust let x: Result = Err("emergency failure"); assert_eq!(unsafe { x.unwrap_err_unchecked() }, "emergency failure"); ``` -------------------------------- ### Copying Result Contents Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Examples of using .copied() on Result types containing references. ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` -------------------------------- ### Transposing Result and Option Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Example of transposing a Result of an Option into an Option of a Result. ```rust #[derive(Debug, Eq, PartialEq)] struct SomeErr; let x: Result, SomeErr> = Ok(Some(5)); let y: Option> = Some(Ok(5)); assert_eq!(x.transpose(), y); ``` -------------------------------- ### Apply CropRegion to Decoder Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/enum.CropRegion.html Example of using CropRegion with the Decoder to crop a specific area of an image. ```rust use zenjpeg::decode::{Decoder, CropRegion}; // Crop a 100x100 region starting at (50, 50) let result = Decoder::new() .crop(CropRegion::pixels(50, 50, 100, 100)) .decode(&jpeg_data, enough::Unstoppable)?; assert_eq!(result.width(), 100); assert_eq!(result.height(), 100); ``` -------------------------------- ### Chain fallible operations with and_then Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Use and_then to chain operations that return a Result. The first example demonstrates basic usage, while the second shows file system metadata retrieval. ```rust assert_eq!(Ok(2).and_then(sq_then_to_string), Ok(4.to_string())); assert_eq!(Ok(1_000_000).and_then(sq_then_to_string), Err("overflowed")); assert_eq!(Err("not a number").and_then(sq_then_to_string), Err("not a number")); ``` ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Checking Result Status Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Examples of checking if a Result is Ok or Err. ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` ```rust let x: Result = Ok(-3); assert_eq!(x.is_err(), false); let x: Result = Err("Some error message"); assert_eq!(x.is_err(), true); ``` -------------------------------- ### Generate Mozjpeg Quantization Tables Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.MozjpegTables.html Demonstrates how to generate quantization tables using standard or custom presets for a specific quality level. ```rust use zenjpeg::encode::{MozjpegTables, QuantTablePreset}; // Standard mozjpeg quality 85 with default (Robidoux) tables let tables = MozjpegTables::generate(85, QuantTablePreset::default()); // Or with a specific preset let tables = MozjpegTables::generate(75, QuantTablePreset::MssimTuned); ``` -------------------------------- ### Decode JPEG with Decoder Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Demonstrates basic decoding using default settings and configuring output for f32 sRGB. ```rust use zenjpeg::decoder::Decoder; // Default (u8 sRGB, fastest) let result = Decoder::new().decode(&jpeg_data, enough::Unstoppable)?; let pixels: &[u8] = result.pixels_u8().unwrap(); // f32 sRGB with unclamped IDCT let result = Decoder::new() .output_target(OutputTarget::SrgbF32) .decode(&jpeg_data, enough::Unstoppable)?; let pixels: &[f32] = result.pixels_f32().unwrap(); ``` -------------------------------- ### Configure JPEG encoding parameters Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/index.html Shows how to customize encoding settings for different color modes and quality metrics. ```rust use zenjpeg::encoder::{EncoderConfig, Quality, ChromaSubsampling, XybSubsampling}; // YCbCr (standard JPEG) - reusable config let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .progressive(true) // Progressive JPEG (~3% smaller) .optimize_huffman(true) // Optimal Huffman tables (default) .sharp_yuv(true) // Better color edges (~3x slower) .restart_mcu_rows(4); // MCU rows between restart markers (default) // XYB (perceptual color space) let config = EncoderConfig::xyb(85, XybSubsampling::BQuarter) .progressive(true); // Grayscale let config = EncoderConfig::grayscale(85); // Quality can also use enum variants: let config = EncoderConfig::ycbcr(Quality::ApproxMozjpeg(80), ChromaSubsampling::Quarter); let config = EncoderConfig::ycbcr(Quality::ApproxSsim2(90.0), ChromaSubsampling::None); let config = EncoderConfig::ycbcr(Quality::ApproxButteraugli(1.0), ChromaSubsampling::Quarter); ``` -------------------------------- ### Apply pre-blur to EncoderConfig Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Demonstrates setting a Gaussian blur sigma value to optimize file size before encoding. ```rust let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .pre_blur(0.4); ``` -------------------------------- ### OptimizationPreset Methods Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/enum.OptimizationPreset.html Methods available on the OptimizationPreset enum to query configuration details. ```APIDOC ## pub fn all() -> impl Iterator Returns an iterator over all available preset variants. ## pub const fn is_progressive(self) -> bool Returns true if the preset uses progressive encoding. ## pub const fn uses_trellis(self) -> bool Returns true if the preset enables trellis quantization. ## pub const fn uses_aq(self) -> bool Returns true if the preset uses jpegli adaptive quantization (AQ). ## pub const fn quant_table_source(self) -> QuantTableSource Returns the quantization table source for the preset. ## pub const fn scan_strategy(self) -> ScanStrategy Returns the scan strategy for the preset. ## pub const fn name(self) -> &'static str Returns the short name of the preset for display or logging purposes. ``` -------------------------------- ### Configure ZenJPEG dependencies Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/index.html Various Cargo.toml configurations for different use cases, including decoder support, parallel processing, and UltraHDR. ```toml zenjpeg = { version = "0.6", features = ["decoder"] } ``` ```toml zenjpeg = "0.6" ``` ```toml zenjpeg = { version = "0.6", features = ["decoder", "parallel"] } ``` ```toml zenjpeg = { version = "0.6", default-features = false } ``` ```toml zenjpeg = { version = "0.6", features = ["decoder", "ultrahdr"] } ``` -------------------------------- ### Apply Custom Encoding Tables Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Demonstrates how to apply and modify custom encoding tables for experimentation, bypassing standard quality scaling. ```rust use zenjpeg::encode::{EncoderConfig, ChromaSubsampling}; use zenjpeg::encode::tuning::EncodingTables; let mut tables = EncodingTables::default_ycbcr(); tables.scale_quant(0, 0, 0.8); // Reduce DC quantization ``` -------------------------------- ### Creating and using an EncodeRequest Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncodeRequest.html Demonstrates how to create an EncodeRequest from an EncoderConfig and use it to encode image data. ```rust use zenjpeg::encoder::{EncoderConfig, ChromaSubsampling}; let config = EncoderConfig::ycbcr(85.0, ChromaSubsampling::Quarter); // Reuse config with different metadata per image let jpeg1 = config.request() .icc_profile(&srgb_bytes) .encode(&pixels1, 1920, 1080)?; ``` -------------------------------- ### EncoderConfig and Request Pattern Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/index.html Demonstrates how to create a reusable EncoderConfig and apply per-image metadata using the request pattern. ```APIDOC ## EncoderConfig and Request Pattern ### Description Use `EncoderConfig` to define global encoding settings like quality and subsampling. Use the `.request()` method to apply specific metadata (ICC profiles, EXIF data) per image before calling `.encode()`. ### Methods - **EncoderConfig::ycbcr(quality, subsampling)**: Initializes a new configuration. - **.auto_optimize(bool)**: Enables or disables automatic optimization. - **.progressive(bool)**: Sets progressive encoding mode. - **.request()**: Creates a request builder for specific image metadata. - **.icc_profile(bytes)**: Sets the ICC profile for the image. - **.exif(Exif)**: Sets EXIF metadata. - **.encode(pixels, width, height)**: Encodes the image data. ``` -------------------------------- ### Estimate Memory Usage for Decoding Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Calculate the peak memory required for decoding an image of specific dimensions before starting the process. ```rust use zenjpeg::decode::Decoder; let decoder = Decoder::new(); let estimated = decoder.estimate_memory_usage(4096, 4096); println!("Estimated peak memory: {} MB", estimated / 1024 / 1024); ``` -------------------------------- ### Calculate Product of Result Items Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Demonstrates using the product method on an iterator of Results, which short-circuits on the first Err encountered. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### Use Unstoppable in a function Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.Unstoppable.html Example showing how to pass Unstoppable to a function expecting a Stop trait implementation when cancellation is not required. ```rust use enough::{Stop, Unstoppable}; fn process(data: &[u8], stop: impl Stop) -> Vec { // ... } // Caller doesn't need cancellation let data = [1u8, 2, 3]; let result = process(&data, Unstoppable); ``` -------------------------------- ### Perform an image encoding request Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncodeRequest.html Demonstrates how to configure an encoding request with an ICC profile and execute the encoding process. ```rust let jpeg2 = config.request() .icc_profile(&p3_bytes) .encode(&pixels2, 3840, 2160)?; ``` -------------------------------- ### HuffmanTableSet::from_standard Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.HuffmanTableSet.html Builds a HuffmanTableSet using the standard JPEG Annex K tables defined in ITU-T T.81. ```APIDOC ## pub fn from_standard() -> Result ### Description Builds tables from the JPEG standard Huffman tables (Annex K of ITU-T T.81). These tables are defined in the JPEG specification and are generally less efficient than the default trained tables. ### Returns - **Result** - A Result containing the initialized HuffmanTableSet or an error. ``` -------------------------------- ### Into Ok Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Result.html Returns the Ok value without panicking, intended for infallible results. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### Exif::raw Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/enum.Exif.html Creates an Exif instance from raw TIFF bytes. The bytes should not include the APP1 prefix. ```APIDOC ## pub fn raw(bytes: impl Into>) -> Self ### Description Creates an EXIF instance from raw TIFF bytes. The provided bytes should be raw TIFF data without the 'Exif\0\0' APP1 prefix, as the encoder adds that automatically. ### Parameters - **bytes** (impl Into>) - Required - The raw TIFF data bytes. ``` -------------------------------- ### Manage Resource Limits and Cancellation Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/index.html Configure memory and pixel limits for DoS protection and implement cooperative cancellation using a stop token. ```rust use zenjpeg::decoder::Decoder; use zenjpeg::types::Limits; use enough::Unstoppable; // Set resource limits (DoS protection) let decoder = Decoder::new() .max_pixels(100_000_000) // 100 megapixels max .max_memory(512_000_000); // 512 MB max allocation // Or use Limits struct let limits = Limits { max_pixels: Some(100_000_000), max_memory: Some(512_000_000), max_output: None, }; let decoder = Decoder::new().limits(limits); // Custom stop token for cancellation let result = decoder.decode(data, &my_cancel_token)?; ``` -------------------------------- ### Perform basic JPEG encoding Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/index.html Demonstrates the standard workflow for encoding RGB bytes into a JPEG using YCbCr configuration. ```rust use zenjpeg::encoder::{EncoderConfig, ChromaSubsampling, PixelLayout, Unstoppable}; let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter); let mut enc = config.encode_from_bytes(1920, 1080, PixelLayout::Rgb8Srgb)?; enc.push_packed(&rgb_bytes, Unstoppable)?; let jpeg = enc.finish()?; ``` -------------------------------- ### aq_enabled Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Enable or disable adaptive quantization (jpegli AQ). ```APIDOC ## pub fn aq_enabled(self, enable: bool) -> Self ### Description Enable or disable adaptive quantization (jpegli AQ). When enabled (default), the encoder computes per-block AQ strengths from luminance data. ### Parameters - **enable** (bool) - Required - Enable or disable adaptive quantization. ``` -------------------------------- ### Create an encode request with metadata Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Shows how to generate an EncodeRequest from a base configuration to apply per-image metadata like ICC profiles and EXIF data. ```rust use zenjpeg::encoder::{EncoderConfig, ChromaSubsampling, Exif, Orientation}; let config = EncoderConfig::ycbcr(85.0, ChromaSubsampling::Quarter); // Reuse config, vary metadata per image let jpeg = config.request() .icc_profile(&srgb_bytes) .exif(Exif::build().orientation(Orientation::Rotate90)) .encode(&pixels, 1920, 1080)?; ``` -------------------------------- ### recommended_quality Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/detect/struct.JpegProbe.html Returns the recommended zenjpeg quality for re-encoding, aiming for a butteraugli delta of 0.3 or less. ```APIDOC ## fn recommended_quality(&self) -> Quality ### Description Returns the lowest quality level that keeps butteraugli delta ≤ 0.3 from the source — barely perceptible degradation. ``` -------------------------------- ### Decoder Configuration and Request Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/type.Decoder.html Methods for configuring the decoder and initiating a decode request. ```APIDOC ## Decoder Configuration ### pub fn new() -> Self Creates a new decoder configuration with default settings. ### pub fn output_format(self, format: PixelFormat) -> Self Sets the output pixel format. ### pub fn chroma_upsampling(self, method: ChromaUpsampling) -> Self Sets the chroma upsampling method (Triangle or NearestNeighbor). ### pub fn idct_method(self, method: IdctMethod) -> Self Sets the integer IDCT algorithm (Jpegli or Libjpeg). ### pub fn deblock(self, mode: DeblockMode) -> Self Enable post-decode deblocking to reduce JPEG block artifacts. ### pub fn max_pixels(self, pixels: u64) -> Self Sets the maximum number of pixels allowed for DoS protection. ### pub fn max_memory(self, bytes: u64) -> Self Sets the maximum memory allowed for allocations during decoding. ### pub fn limits(self, limits: Limits) -> Self Sets resource limits from a Limits struct. ### pub fn request<'a>(&'a self, data: &'a [u8]) -> DecodeRequest<'a> Creates a per-job decode request binding this config with JPEG data. ``` -------------------------------- ### pub fn preserve(self, config: PreserveConfig) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Configure what metadata and secondary images to preserve during decode. ```APIDOC ## pub fn preserve(self, config: PreserveConfig) -> Self ### Description Configure what metadata and secondary images to preserve during decode. ### Parameters - **config** (PreserveConfig) - Required - The configuration for metadata and secondary image preservation. ``` -------------------------------- ### pub fn max_pixels(self, pixels: u64) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Sets the maximum number of pixels allowed for DoS protection. Default is 100 megapixels. Set to 0 for unlimited. ```APIDOC ## pub fn max_pixels(self, pixels: u64) -> Self ### Description Sets the maximum number of pixels allowed (for DoS protection). Default is 100 megapixels. Set to 0 for unlimited. ### Parameters - **pixels** (u64) - Required - Maximum number of pixels allowed. ``` -------------------------------- ### ProfileGuard::new Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/profile/struct.ProfileGuard.html Creates a new instance of ProfileGuard with a specified name. ```APIDOC ## pub fn new(_name: &'static str) -> Self ### Description Creates a new ProfileGuard instance. This is typically used to start a profiling scope. ### Parameters - **_name** (&'static str) - Required - The name associated with the profile guard. ``` -------------------------------- ### Request Decode with Pool Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Shows how to create a decode request using a configuration and optionally binding it to a thread pool. ```rust use zenjpeg::decode::{Decoder, DecodePool}; let decoder = Decoder::new().chroma_upsampling(ChromaUpsampling::NearestNeighbor); let pool = DecodePool::new(); // With pool (server) let result = decoder.request(&jpeg_data) .pool(&pool) .decode()?; // Without pool (standalone) let result = decoder.request(&jpeg_data).decode()?; ``` -------------------------------- ### Configure Decoder Dependency Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/index.html Add the zenjpeg dependency with the decoder feature enabled in your Cargo.toml. ```toml [dependencies] zenjpeg = { version = "0.6", features = ["decoder"] } ``` -------------------------------- ### pub fn copyright(self, copyright: impl Into) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.ExifFields.html Sets the EXIF copyright tag for the image metadata. ```APIDOC ## pub fn copyright(self, copyright: impl Into) -> Self ### Description Set the EXIF copyright tag. Standard format is “Copyright, Owner Name, Year” but any string works. ### Parameters - **copyright** (impl Into) - Required - The copyright string to set. ``` -------------------------------- ### Encode from raw bytes Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Demonstrates creating an encoder instance from raw byte buffers with a specified pixel layout. ```rust use zenjpeg::{EncoderConfig, ChromaSubsampling, PixelLayout, Unstoppable}; let config = EncoderConfig::ycbcr(85.0, ChromaSubsampling::Quarter); let mut enc = config.encode_from_bytes(1920, 1080, PixelLayout::Rgb8Srgb)?; enc.push_packed(&rgb_bytes, Unstoppable)?; let jpeg = enc.finish()?; ``` -------------------------------- ### then Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/lossless/enum.LosslessTransform.html Composes two transforms by applying them in sequence. ```APIDOC ### pub fn then(self, other: Self) -> Self Returns a new transform that is the result of applying `self` followed by `other`. ``` -------------------------------- ### MozjpegTables::generate_ex Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.MozjpegTables.html Generates encoding tables with explicit control over baseline JPEG compatibility clamping. ```APIDOC ## MozjpegTables::generate_ex(quality: u8, preset: QuantTablePreset, force_baseline: bool) -> Box ### Description Generates encoding tables with baseline clamping control. This is similar to `generate`, but allows explicit control over whether to clamp values to 255 for baseline JPEG compatibility. ### Parameters - **quality** (u8) - Quality level 1-100. - **preset** (QuantTablePreset) - Which base table variant to use. - **force_baseline** (bool) - If true, clamp all values to 255 (baseline JPEG). ``` -------------------------------- ### Configuration Methods Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Methods available on the DecodeConfig builder to customize the decoding process. ```APIDOC ## Configuration Methods ### strictness(self, strictness: Strictness) -> Self Sets the strictness level for error handling. Options include Strict, Balanced (default), Lenient, and Permissive. ### strict(self) -> Self Convenience method to set strict mode (fail on any recoverable error). ### lenient(self) -> Self Convenience method to set lenient mode (recover from all errors). ### permissive(self) -> Self Convenience method to set permissive mode (maximum libjpeg-turbo compatibility). ### output_target(self, target: OutputTarget) -> Self Sets the output target controlling precision, transfer function, and IDCT variant. ### gain_map(self, handling: GainMapHandling) -> Self Sets how UltraHDR gain maps are handled. ### auto_orient(self, enable: bool) -> Self Controls automatic EXIF orientation correction. Enabled by default. ### transform(self, transform: LosslessTransform) -> Self Sets an explicit lossless transform to apply during decode in DCT-coefficient space. ### orientation(self, hint: OrientationHint) -> Self Sets the orientation strategy for decode, combining EXIF auto-correction and explicit transforms. ### dequant_bias(self, enable: bool) -> Self Enables optimal Laplacian dequantization biases for higher quality output at the cost of performance. ### crop(self, region: CropRegion) -> Self Sets a crop region for decode to output only a sub-region of the image. ### num_threads(self, n: usize) -> Self Sets the number of threads for parallel decode paths. 0 (default) uses the global thread pool. ``` -------------------------------- ### recommended_subsampling Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/detect/struct.JpegProbe.html Returns the recommended chroma subsampling mode that matches the source JPEG. ```APIDOC ## fn recommended_subsampling(&self) -> ChromaSubsampling ### Description Returns the recommended ChromaSubsampling matching the source JPEG to preserve the original subsampling mode. ``` -------------------------------- ### finish_into(&mut self, output: &mut Vec) -> Result<()> Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.BytesEncoder.html Completes the encoding process and writes the resulting JPEG data directly into the provided buffer. ```APIDOC ## pub fn finish_into(&mut self, output: &mut Vec) -> Result<()> ### Description Finish encoding, writing directly to the provided buffer. This is the most efficient way to complete encoding as it avoids intermediate allocations. The buffer is cleared before writing. ### Example ```rust let mut output = Vec::new(); encoder.finish_into(&mut output)?; // output now contains the JPEG data ``` ``` -------------------------------- ### Encode RGB pixels using EncoderConfig Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Demonstrates creating an encoder from RGB pixel types and performing a streaming encode operation. ```rust use rgb::RGB; use zenjpeg::{EncoderConfig, ChromaSubsampling, Unstoppable}; let config = EncoderConfig::ycbcr(85.0, ChromaSubsampling::Quarter); let mut enc = config.encode_from_rgb::>(1920, 1080)?; enc.push_packed(&pixels, Unstoppable)?; let jpeg = enc.finish()?; ``` -------------------------------- ### pub fn limits(self, limits: Limits) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Sets resource limits from a Limits struct. ```APIDOC ## pub fn limits(self, limits: Limits) -> Self ### Description Sets resource limits from a Limits struct. This applies max_pixels and max_memory from the Limits struct. ### Parameters - **limits** (Limits) - Required - The limits configuration struct. ``` -------------------------------- ### Configure Decoder Strictness Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodeConfig.html Demonstrates setting different strictness levels for error handling during the decoding process. ```rust use zenjpeg::decode::{Decoder, Strictness}; // Strict mode for validation let decoder = Decoder::new().strictness(Strictness::Strict); // Balanced mode (default) for production let decoder = Decoder::new().strictness(Strictness::Balanced); // Lenient mode for corrupt file recovery let decoder = Decoder::new().strictness(Strictness::Lenient); // Permissive mode for maximum compatibility let decoder = Decoder::new().strictness(Strictness::Permissive); ``` -------------------------------- ### pub fn orientation(self, orientation: Orientation) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.ExifFields.html Sets the EXIF orientation tag, which determines how image viewers should rotate or flip the image for display. ```APIDOC ## pub fn orientation(self, orientation: Orientation) -> Self ### Description Sets the EXIF orientation tag. This controls how image viewers should rotate/flip the image for display. ### Parameters - **orientation** (Orientation) - Required - The orientation value to apply. ``` -------------------------------- ### Configure Huffman Strategy Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Sets the Huffman table strategy using booleans, explicit strategies, or custom table sets. Progressive mode requires HuffmanStrategy::Optimize. ```rust use zenjpeg::encoder::{EncoderConfig, HuffmanStrategy, HuffmanTableSet}; // Boolean (same as old optimize_huffman) let config = EncoderConfig::ycbcr(85, sub).huffman(true); // Explicit strategy let config = EncoderConfig::ycbcr(85, sub).huffman(HuffmanStrategy::FixedAnnexK); // Custom tables let tables = HuffmanTableSet::annex_k()?; let config = EncoderConfig::ycbcr(85, sub).huffman(tables); ``` -------------------------------- ### Estimate JPEG decoding resources in Rust Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/heuristics/fn.estimate_decode.html Calculates output buffer size, peak memory, and typical decoding time for a given image resolution and pixel format. ```rust use zenjpeg::heuristics::estimate_decode; use zenjpeg::decoder::PixelFormat; let est = estimate_decode(1920, 1080, PixelFormat::Rgb); println!("Output buffer: {:.1} MB", est.output_bytes as f64 / 1_000_000.0); println!("Peak memory: {:.1} MB", est.peak_memory_bytes as f64 / 1_000_000.0); println!("Time: {:.0}ms (typical)", est.time_ms); ``` -------------------------------- ### PixelLayout Conversions Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/enum.PixelLayout.html Conversion methods between PixelLayout and legacy PixelFormat. ```APIDOC ## impl From for PixelLayout Converts from legacy PixelFormat to explicit PixelLayout. ## impl From for PixelFormat Converts from PixelLayout to legacy PixelFormat. ``` -------------------------------- ### MozjpegTables::generate Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.MozjpegTables.html Generates encoding tables using mozjpeg’s quality scaling formula based on a provided quality level and preset. ```APIDOC ## MozjpegTables::generate(quality: u8, preset: QuantTablePreset) -> Box ### Description Generates encoding tables using mozjpeg’s quality scaling formula. The quality value is converted to a scale factor using the standard libjpeg/mozjpeg formula. ### Parameters - **quality** (u8) - Quality level 1-100 (higher = better quality, larger files). - **preset** (QuantTablePreset) - Which base table variant to use. ### Returns An EncodingTables object with the scaled luminance and chrominance tables. ``` -------------------------------- ### Implement Stop for Option in hot loops Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/trait.Stop.html Demonstrates using Option to optimize hot loops by conditionally checking stop status. ```rust use enough::{Stop, StopReason, Unstoppable}; fn hot_loop(stop: &dyn Stop) -> Result<(), StopReason> { let stop = stop.may_stop().then_some(stop); for i in 0..1000 { stop.check()?; // None → Ok(()), Some → delegates } Ok(()) } assert!(hot_loop(&Unstoppable).is_ok()); ``` -------------------------------- ### Import Encoder API Components Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/index.html Import core types, configuration options, and result types from the encoder module. ```rust use zenjpeg::encoder::{ // Core types EncoderConfig, // Builder for encoder configuration BytesEncoder, // Encoder for raw byte buffers RgbEncoder, // Encoder for rgb crate types YCbCrPlanarEncoder, // Encoder for planar YCbCr // Configuration Quality, // Quality settings (ApproxJpegli, ApproxMozjpeg, etc.) PixelLayout, // Pixel format for raw bytes ChromaSubsampling, // 4:4:4, 4:2:0, 4:2:2, 4:4:0 ColorMode, // YCbCr, XYB, Grayscale DownsamplingMethod, // Box, GammaAware, GammaAwareIterative // Cancellation Stop, // Trait for cancellation tokens Unstoppable, // Use when no cancellation needed // Results Error, Result, // Error handling }; ``` -------------------------------- ### Configure Encoder for JPEG Quality Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Initializes an EncoderConfig with specific quality and chroma subsampling settings, matching the behavior of jpeg_set_quality. ```rust // Match jpeg_set_quality() behavior (2 tables) let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .separate_chroma_tables(false); ``` -------------------------------- ### Implement cooperative cancellation Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/index.html Demonstrates how to pass a cancellation token to push methods, supporting both non-cancellable operations and atomic boolean flags. ```rust use zenjpeg::encoder::Unstoppable; use std::sync::atomic::AtomicBool; // No cancellation enc.push_packed(&data, Unstoppable)?; // With AtomicBool let cancel = AtomicBool::new(false); enc.push_packed(&data, &cancel)?; ``` -------------------------------- ### validate Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Validate the configuration, returning an error for invalid combinations. ```APIDOC ## pub fn validate(&self) -> Result<()> ### Description Validate the configuration, returning an error for invalid combinations, such as progressive mode with disabled Huffman optimization. ``` -------------------------------- ### Encode JPEG from Raw Bytes Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/index.html Create an encoder configuration and encode raw RGB bytes into a JPEG image. ```rust use zenjpeg::encoder::{EncoderConfig, ChromaSubsampling, PixelLayout, Unstoppable}; // Create reusable config (quality + color mode in constructor) let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .progressive(true); // Encode from raw bytes let mut enc = config.encode_from_bytes(1920, 1080, PixelLayout::Rgb8Srgb)?; enc.push_packed(&rgb_bytes, Unstoppable)?; let jpeg = enc.finish()?; ``` -------------------------------- ### Streaming Encoder Creation Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncodeRequest.html Methods to initialize streaming encoders from various input types. ```APIDOC ## Streaming Encoder Methods - **encode_from_bytes(width: u32, height: u32, layout: PixelLayout) -> Result**: Create a streaming encoder from raw byte input. - **encode_from_rgb(width: u32, height: u32) -> Result>**: Create a streaming encoder from rgb crate pixel types. - **encode_from_ycbcr_planar(width: u32, height: u32) -> Result**: Create a streaming encoder from planar YCbCr data. ``` -------------------------------- ### quant_source Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Sets the quantization table source. This is a convenience method, though quant_table_config is preferred for full control. ```APIDOC ## pub fn quant_source(self, source: QuantTableSource) -> Self ### Description Sets the quantization table source. Convenience method for setting the source. ### Parameters - **source** (QuantTableSource) - Required - The source for the quantization tables. ``` -------------------------------- ### pub fn to_bytes(&self) -> Option> Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.ExifFields.html Converts the configured EXIF fields into raw TIFF bytes. ```APIDOC ## pub fn to_bytes(&self) -> Option> ### Description Convert to raw TIFF bytes. Returns None if no fields are set. ### Returns - **Option>** - The raw TIFF bytes if fields are present, otherwise None. ``` -------------------------------- ### pub fn tables(self, tables: Box) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Applies custom encoding tables for experimentation, replacing default quantization tables and zero-bias configuration. ```APIDOC ## pub fn tables(self, tables: Box) -> Self ### Description Apply custom encoding tables for experimentation. This replaces both quantization tables and zero-bias configuration with values from the provided `EncodingTables`. ### Notes - Tables must match the color mode (YCbCr or XYB). - When using `ScalingParams::Exact`, quality scaling is bypassed. - When using `ScalingParams::Scaled`, tables are scaled by quality. ``` -------------------------------- ### Using may_stop with dyn Stop Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/trait.Stop.html Demonstrates using may_stop to optimize hot loops when working with dynamic dispatch. ```rust use enough::{Stop, StopReason, Unstoppable}; fn process(stop: &dyn Stop) -> Result<(), StopReason> { let stop = stop.may_stop().then_some(stop); // stop is Option<&dyn Stop>, which impl Stop: // None → check() always returns Ok(()), Some → delegates for i in 0..100 { stop.check()?; } Ok(()) } // Unstoppable: may_stop() returns false, so stop is None assert!(process(&Unstoppable).is_ok()); ``` -------------------------------- ### DecodePool::new Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodePool.html Creates a new instance of DecodePool with the default parallel threshold of 4. ```APIDOC ## pub fn new() -> Self ### Description Creates a new decode pool with the default parallel threshold (4). This threshold balances single-image latency and total system throughput. ``` -------------------------------- ### pub fn restart_mcu_rows(self, rows: u16) -> Self Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Sets the restart marker interval in MCU rows. Restart markers enable parallel decoding, error recovery, and random access. ```APIDOC ## pub fn restart_mcu_rows(self, rows: u16) -> Self ### Description Set the restart marker interval in MCU rows (default: 4). This guarantees MCU-row-aligned restart boundaries, which is required for the fused chroma upsample and color conversion decode path. ### Parameters - **rows** (u16) - The number of MCU rows between restart markers. Use 0 to disable restart markers. ``` -------------------------------- ### Profile encoder phases with profile_scope Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/profile/index.html Use profile_scope! to measure execution time of a block and ProfileStats::print_summary to output results. ```rust profile_scope!("dct"); // ... do DCT work ... // automatically records time when scope ends // At end of encode: ProfileStats::print_summary(); ``` -------------------------------- ### Limits Configuration Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.Limits.html The Limits struct provides builder methods to configure resource constraints for encoding and decoding operations. ```APIDOC ## struct Limits ### Description Resource limits for encoding and decoding operations. All fields are `Option` where `None` means no limit. ### Methods - **max_pixels(pixels: u64) -> Self**: Sets the maximum number of pixels allowed (width * height). - **max_memory(bytes: u64) -> Self**: Sets the maximum total memory allocation in bytes. - **max_output(bytes: u64) -> Self**: Sets the maximum output size in bytes. - **effective_max_pixels() -> u64**: Returns the pixel limit, or `u64::MAX` if unlimited. - **effective_max_memory() -> u64**: Returns the memory limit, or `u64::MAX` if unlimited. - **effective_max_output() -> u64**: Returns the output size limit, or `u64::MAX` if unlimited. ### Example ```rust use zenjpeg::encoder::Limits; let limits = Limits::default() .max_pixels(100_000_000) .max_memory(512 * 1024 * 1024) .max_output(50 * 1024 * 1024); ``` ``` -------------------------------- ### Estimate Memory Usage for Encoding Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/index.html Calculate typical and upper-bound memory requirements for a specific image resolution and encoder configuration. ```rust use zenjpeg::{EncoderConfig, ChromaSubsampling}; let config = EncoderConfig::ycbcr(85.0, ChromaSubsampling::Quarter); // Typical estimate let estimate = config.estimate_memory(1920, 1080); // Guaranteed upper bound let ceiling = config.estimate_memory_ceiling(1920, 1080); ``` -------------------------------- ### Accessing JPEG Probe Data Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/decoder/struct.DecodedExtras.html Retrieve and display encoder information and quality estimates from the JPEG header analysis. ```rust let extras = decoded.extras().unwrap(); if let Some(probe) = extras.probe() { println!("Encoder: {:?}", probe.encoder); println!("Quality: {:.0} ({:?})", probe.quality.value, probe.quality.scale); } ``` -------------------------------- ### Configure Quantization Tables Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Sets the quantization table configuration using the type-safe QuantTableConfig enum. ```rust use zenjpeg::encode::{EncoderConfig, ChromaSubsampling, QuantTableConfig}; let config = EncoderConfig::ycbcr(85, ChromaSubsampling::Quarter) .quant_table_config(QuantTableConfig::MozjpegRobidoux); ``` -------------------------------- ### request Source: https://docs.rs/zenjpeg/0.8.4/zenjpeg/encoder/struct.EncoderConfig.html Create a per-image encode request from this config. ```APIDOC ## pub fn request(&self) -> EncodeRequest<'_> ### Description Create a per-image encode request from this config. Returns an EncodeRequest that can bind per-image metadata (ICC, EXIF, XMP) and controls without modifying the reusable config. ```