jxl_oxide

Struct JxlImage

Source
pub struct JxlImage { /* private fields */ }
Expand description

JPEG XL image.

Implementations§

Source§

impl JxlImage

§Constructors and data-feeding methods

Source

pub fn builder() -> JxlImageBuilder

Creates a decoder builder with default options.

Source

pub fn read_with_defaults(reader: impl Read) -> Result<JxlImage>

Reads an image from the reader with default options.

Source

pub fn open_with_defaults(path: impl AsRef<Path>) -> Result<JxlImage>

Opens an image in the filesystem with default options.

Source

pub fn feed_bytes(&mut self, buf: &[u8]) -> Result<usize>

Feeds more data into the decoder.

Returns total consumed bytes from the buffer.

Source

pub fn finalize(&mut self) -> Result<()>

Signals the end of bitstream.

This is automatically done if open() or read() is used to decode the image.

Source§

impl JxlImage

§Image and decoder metadata accessors

Source

pub fn image_header(&self) -> &ImageHeader

Returns the image header.

Source

pub fn width(&self) -> u32

Returns the image width with orientation applied.

Source

pub fn height(&self) -> u32

Returns the image height with orientation applied.

Source

pub fn original_icc(&self) -> Option<&[u8]>

Returns the original ICC profile embedded in the image.

Source

pub fn rendered_icc(&self) -> Vec<u8>

Returns the ICC profile that describes rendered images.

The returned profile will change if different color encoding is specified using request_icc or request_color_encoding.

Source

pub fn rendered_cicp(&self) -> Option<[u8; 4]>

Returns the CICP tag of the color encoding of rendered images, if there’s any.

Source

pub fn pixel_format(&self) -> PixelFormat

Returns the pixel format of the rendered image.

Source

pub fn hdr_type(&self) -> Option<HdrType>

Returns what HDR transfer function the image uses, if there’s any.

Returns None if the image is not HDR one.

Source

pub fn render_spot_color(&self) -> bool

Returns whether the spot color channels will be rendered.

Source

pub fn set_render_spot_color(&mut self, render_spot_color: bool) -> &mut Self

Sets whether the spot colour channels will be rendered.

Source

pub fn aux_boxes(&self) -> &AuxBoxList

Returns the list of auxiliary boxes in the JPEG XL container.

The list may contain Exif and XMP metadata.

Source

pub fn num_loaded_keyframes(&self) -> usize

Returns the number of currently loaded keyframes.

Source

pub fn num_loaded_frames(&self) -> usize

Returns the number of currently loaded frames, including frames that are not displayed directly.

Source

pub fn is_loading_done(&self) -> bool

Returns whether the image is loaded completely, without missing animation keyframes or partially loaded frames.

Source

pub fn frame_by_keyframe(&self, keyframe_index: usize) -> Option<&IndexedFrame>

Returns frame data by keyframe index.

Source

pub fn frame_header(&self, keyframe_index: usize) -> Option<&FrameHeader>

Returns the frame header for the given keyframe index, or None if the keyframe does not exist.

Source

pub fn frame(&self, frame_idx: usize) -> Option<&IndexedFrame>

Returns frame data by frame index, including frames that are not displayed directly.

There are some situations where a frame is not displayed directly:

  • It may be marked as reference only, and meant to be only used by other frames.
  • It may contain LF image (which is 8x downsampled version) of another VarDCT frame.
  • Zero duration frame that is not the last frame of image is blended with following frames and displayed together.
Source

pub fn frame_offset(&self, frame_index: usize) -> Option<usize>

Returns the offset of frame within codestream, in bytes.

Source

pub fn pool(&self) -> &JxlThreadPool

Returns the thread pool used by the renderer.

Source

pub fn reader(&self) -> &ContainerDetectingReader

Returns the internal reader.

Source§

impl JxlImage

§Color management methods

Source

pub fn set_cms( &mut self, cms: impl ColorManagementSystem + Send + Sync + 'static, )

Sets color management system implementation to be used by the renderer.

Source

pub fn request_icc(&mut self, icc_profile: &[u8]) -> Result<()>

Requests the decoder to render in specific color encoding, described by an ICC profile.

§Errors

This function will return an error if it cannot parse the ICC profile.

Source

pub fn request_color_encoding(&mut self, color_encoding: EnumColourEncoding)

Requests the decoder to render in specific color encoding, described by EnumColourEncoding.

Source§

impl JxlImage

§Rendering to image buffers

Source

pub fn render_frame(&self, keyframe_index: usize) -> Result<Render>

Renders the given keyframe.

Source

pub fn render_frame_cropped(&self, keyframe_index: usize) -> Result<Render>

Renders the given keyframe with optional cropping region.

Source

pub fn render_loading_frame(&mut self) -> Result<Render>

Renders the currently loading keyframe.

Source

pub fn render_loading_frame_cropped(&mut self) -> Result<Render>

Renders the currently loading keyframe with optional cropping region.

Source

pub fn set_image_region(&mut self, region: CropInfo) -> &mut Self

Sets the cropping region (region of interest).

Subsequent rendering methods will crop the image buffer according to the region.

Source§

impl JxlImage

§JPEG bitstream reconstruction

Source

pub fn jpeg_reconstruction_status(&self) -> JpegReconstructionStatus

Returns availability and validity of JPEG bitstream reconstruction data.

Source

pub fn reconstruct_jpeg(&self, jpeg_output: impl Write) -> Result<()>

Reconstructs JPEG bitstream and writes the image to writer.

§Errors

Returns an error if the reconstruction data is not available, incomplete or invalid, or if there was an error writing the image.

Note that reconstruction may fail even if jpeg_reconstruction_status returned Available.

Trait Implementations§

Source§

impl Debug for JxlImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more