pub struct EncodeRequest<'a> { /* private fields */ }Expand description
An encoding request — binds config + image dimensions + pixel layout.
Created via LosslessConfig::encode_request or LossyConfig::encode_request.
Implementations§
Source§impl<'a> EncodeRequest<'a>
impl<'a> EncodeRequest<'a>
Sourcepub fn with_metadata(self, meta: &'a ImageMetadata<'a>) -> Self
pub fn with_metadata(self, meta: &'a ImageMetadata<'a>) -> Self
Attach image metadata (ICC, EXIF, XMP).
Sourcepub fn with_limits(self, limits: &'a Limits) -> Self
pub fn with_limits(self, limits: &'a Limits) -> Self
Attach resource limits.
Sourcepub fn with_stop(self, stop: &'a dyn Stop) -> Self
pub fn with_stop(self, stop: &'a dyn Stop) -> Self
Attach a cooperative cancellation token.
The encoder will check this periodically and return
EncodeError::Cancelled if stopped.
Sourcepub fn with_source_gamma(self, gamma: f32) -> Self
pub fn with_source_gamma(self, gamma: f32) -> Self
Specify that source pixels use a custom gamma transfer function.
When set, the encoder linearizes u8/u16 pixels with pixel ^ (1/gamma)
instead of the sRGB transfer function, and writes have_gamma=true in
the JXL header. This matches cjxl’s behavior for PNGs with gAMA chunks.
Example: 0.45455 for standard gamma 2.2 encoding (gAMA=45455).
Sourcepub fn with_color_encoding(self, ce: ColorEncoding) -> Self
pub fn with_color_encoding(self, ce: ColorEncoding) -> Self
Override the color encoding written to the JXL header.
When set, this color encoding is used instead of the default (sRGB for
u8/u16, linear sRGB for f32) or any gamma derived from
with_source_gamma.
Use this for HDR content (PQ, HLG) or non-sRGB primaries (BT.2020, Display P3).
Note: this only affects the signaled color encoding in the JXL header.
Pixel linearization for lossy encoding is still controlled by
with_source_gamma(). For float input, pixels are assumed already linear.
Sourcepub fn encode_with_stats(self, pixels: &[u8]) -> Result<EncodeResult>
pub fn encode_with_stats(self, pixels: &[u8]) -> Result<EncodeResult>
Encode pixels and return the JXL bytes together with EncodeStats.
Sourcepub fn encode_into(
self,
pixels: &[u8],
out: &mut Vec<u8>,
) -> Result<EncodeResult>
pub fn encode_into( self, pixels: &[u8], out: &mut Vec<u8>, ) -> Result<EncodeResult>
Encode pixels, appending to an existing buffer. Returns metrics.
Auto Trait Implementations§
impl<'a> Freeze for EncodeRequest<'a>
impl<'a> !RefUnwindSafe for EncodeRequest<'a>
impl<'a> Send for EncodeRequest<'a>
impl<'a> Sync for EncodeRequest<'a>
impl<'a> Unpin for EncodeRequest<'a>
impl<'a> UnsafeUnpin for EncodeRequest<'a>
impl<'a> !UnwindSafe for EncodeRequest<'a>
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
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>
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>
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