Skip to main content

EncodeRequest

Struct EncodeRequest 

Source
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>

Source

pub fn with_metadata(self, meta: &'a ImageMetadata<'a>) -> Self

Attach image metadata (ICC, EXIF, XMP).

Source

pub fn with_limits(self, limits: &'a Limits) -> Self

Attach resource limits.

Source

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.

Source

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).

Source

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.

Source

pub fn encode(self, pixels: &[u8]) -> Result<Vec<u8>>

Encode pixels and return the JXL bytes.

Source

pub fn encode_with_stats(self, pixels: &[u8]) -> Result<EncodeResult>

Encode pixels and return the JXL bytes together with EncodeStats.

Source

pub fn encode_into( self, pixels: &[u8], out: &mut Vec<u8>, ) -> Result<EncodeResult>

Encode pixels, appending to an existing buffer. Returns metrics.

Source

pub fn encode_to(self, pixels: &[u8], dest: impl Write) -> Result<EncodeResult>

Encode pixels, writing to a std::io::Write destination. 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.