Expand description
Encoding API for JPEG XL.
Structs§
- JxlChunked
Frame Input Source - This struct provides callback functions to pass pixel data in a streaming manner instead of requiring the entire frame data in memory at once.
- JxlEncoder
- Opaque structure that holds the JPEG XL encoder.
- JxlEncoder
Frame Settings - Settings and metadata for a single image frame. This includes encoder options for a frame such as compression quality and speed.
- JxlEncoder
Output Processor - The
JxlEncoderOutputProcessorstructure provides an interface for the encoder’s output processing. Users of the library, who want to do streaming encoding, should implement the required callbacks for buffering, writing, seeking (if supported), and setting a finalized position during the encoding process.
Enums§
- JxlEncoder
Error - Error conditions: API usage errors have the 0x80 bit set to 1 Other errors have the 0x80 bit set to 0
- JxlEncoder
Frame Setting Id - Id of encoder options for a frame. This includes options such as setting encoding effort/speed or overriding the use of certain coding tools, for this frame. This does not include non-frame related encoder options such as for boxes.
- JxlEncoder
Status - Return value for multiple encoder functions.
Functions§
- JxlColor
Encoding ⚠SetTo LinearSRGB - Sets a color encoding to be linear sRGB.
- JxlColor
Encoding ⚠SetToSRGB - Sets a color encoding to be sRGB.
- JxlEncoder
AddBox ⚠ - Adds a metadata box to the file format.
JxlEncoderProcessOutputmust be used to effectively write the box to the output.JxlEncoderUseBoxesmust be enabled before using this function. - JxlEncoder
AddChunked ⚠Frame - Adds a frame to the encoder using a chunked input source.
- JxlEncoder
AddImage ⚠Frame - Sets the buffer to read pixels from for the next image to encode. Must call
JxlEncoderSetBasicInfobeforeJxlEncoderAddImageFrame. - JxlEncoder
AddJPEG ⚠Frame - Sets the buffer to read JPEG encoded bytes from for the next frame to encode.
- JxlEncoder
Allow ⚠Expert Options - Enables usage of expert options.
- JxlEncoder
Close ⚠Boxes - Declares that no further boxes will be added with
JxlEncoderAddBox. This function must be called after the last box is added so the encoder knows the stream will be finished. It is not necessary to use this function ifJxlEncoderUseBoxesis not used. Further frames may still be added. - JxlEncoder
Close ⚠Frames - Declares that no frames will be added and
JxlEncoderAddImageFrameandJxlEncoderAddJPEGFramewon’t be called anymore. Further metadata boxes may still be added. This function orJxlEncoderCloseInputmust be called after adding the last frame and the next call toJxlEncoderProcessOutput, or the frame won’t be properly marked as last. - JxlEncoder
Close ⚠Input - Closes any input to the encoder, equivalent to calling
JxlEncoderCloseFramesas well as callingJxlEncoderCloseBoxesif needed. No further input of any kind may be given to the encoder, but furtherJxlEncoderProcessOutputcalls should be done to create the final output. - JxlEncoder
Collect ⚠Stats - Sets the given stats object for gathering various statistics during encoding.
- JxlEncoder
Create ⚠ - Creates an instance of
JxlEncoderand initializes it. - JxlEncoder
Destroy ⚠ - Deinitializes and frees a
JxlEncoderinstance. - JxlEncoder
Distance ⚠From Quality - Maps JPEG-style quality factor to distance.
- JxlEncoder
Flush ⚠Input - Flushes any buffered input in the encoder, ensuring that all available input data has been processed and written to the output.
- JxlEncoder
Frame ⚠Settings Create - Create a new set of encoder options, with all values initially copied from
the
sourceoptions, or set to default ifsourceisNULL. - JxlEncoder
Frame ⚠Settings SetFloat Option - Sets a frame-specific option of float type to the encoder options.
The
JxlEncoderFrameSettingIdargument determines which option is set. - JxlEncoder
Frame ⚠Settings SetOption - Sets a frame-specific option of integer type to the encoder options.
The
JxlEncoderFrameSettingIdargument determines which option is set. - JxlEncoder
GetError ⚠ - Get the (last) error code in case
JxlEncoderStatus::Errorwas returned. - JxlEncoder
GetRequired ⚠Codestream Level - Returns the codestream level required to support the currently configured settings and basic info. This function can only be used at the beginning, before encoding starts, but after setting basic info.
- JxlEncoder
Init ⚠Basic Info - Initializes a
JxlBasicInfostruct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to an 8-bit RGB image, no alpha or any other extra channels. - JxlEncoder
Init ⚠Blend Info - Initializes a
JxlBlendInfostruct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. - JxlEncoder
Init ⚠Extra Channel Info - Initializes a
JxlExtraChannelInfostruct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to an 8-bit channel of the provided type. - JxlEncoder
Init ⚠Frame Header - Initializes a
JxlFrameHeaderstruct to default values. For forwards-compatibility, this function has to be called before values are assigned to the struct fields. The default values correspond to a frame with no animation duration and the ‘replace’ blend mode. After using this function, animation duration must be set, and for composite still, blend settings must be set. - JxlEncoder
Process ⚠Output - Encodes a JPEG XL file using the available bytes.
*avail_outindicates how many output bytes are available, and*next_outpoints to the input bytes.*avail_outwill be decremented by the amount of bytes that have been processed by the encoder and*next_outwill be incremented by the same amount, so*next_outwill now point at the amount of*avail_outunprocessed bytes. - JxlEncoder
Reset ⚠ - Re-initializes a
JxlEncoderinstance, so it can be re-used for encoding another image. All state and settings are reset as if the object was newly created withJxlEncoderCreate, but the memory manager is kept. - JxlEncoder
SetBasic ⚠Info - Sets the global metadata of the image encoded by this encoder.
- JxlEncoder
SetCms ⚠ - Sets the color management system (CMS) that will be used for color conversion (if applicable) during encoding. May only be set before starting encoding. If left unset, the default CMS implementation will be used.
- JxlEncoder
SetCodestream ⚠Level - Sets the feature level of the JPEG XL codestream. Valid values are 5 and 10, or -1 (to choose automatically). Using the minimum required level, or level 5 in most cases, is recommended for compatibility with all decoders.
- JxlEncoder
SetColor ⚠Encoding - Sets the original color encoding of the image encoded by this encoder. This
is an alternative to
JxlEncoderSetICCProfileand only one of these two must be used. This one sets the color encoding as aJxlColorEncoding, while the other sets it as ICC binary data. Must be called afterJxlEncoderSetBasicInfo. - JxlEncoder
SetDebug ⚠Image Callback - Sets the given debug image callback that will be used by the encoder to output various debug images during encoding.
- JxlEncoder
SetExtra ⚠Channel Blend Info - Sets blend info of an extra channel. The blend info of extra channels is set
separately from that of the color channels, the color channels are set with
JxlEncoderSetFrameHeader. - JxlEncoder
SetExtra ⚠Channel Buffer - Sets the buffer to read pixels from for an extra channel at a given index.
The index must be smaller than the
num_extra_channelsin the associatedJxlBasicInfo. Must callJxlEncoderSetExtraChannelInfobeforeJxlEncoderSetExtraChannelBuffer. - JxlEncoder
SetExtra ⚠Channel Distance - Sets the distance level for lossy compression of extra channels.
The distance is as in
JxlEncoderSetFrameDistance(lower = higher quality). If not set, or if set to the special value -1, the distance that was set withJxlEncoderSetFrameDistancewill be used. - JxlEncoder
SetExtra ⚠Channel Info - Sets information for the extra channel at the given index. The index
must be smaller than
num_extra_channelsin the associatedJxlBasicInfo. - JxlEncoder
SetExtra ⚠Channel Name - Sets the name for the extra channel at the given index in UTF-8. The index
must be smaller than the
num_extra_channelsin the associatedJxlBasicInfo. - JxlEncoder
SetFrame ⚠BitDepth - Sets the bit depth of the input buffer.
- JxlEncoder
SetFrame ⚠Distance - Sets the distance level for lossy compression: target max butteraugli
distance, lower = higher quality. Range: 0 .. 25.
0.0 = mathematically lossless (however, use
JxlEncoderSetFrameLosslessinstead to use true lossless, as setting distance to 0 alone is not the only requirement). 1.0 = visually lossless. Recommended range: 0.5 .. 3.0. Default value: 1.0. - JxlEncoder
SetFrame ⚠Header - Sets the frame information for this frame to the encoder. This includes animation information such as frame duration to store in the frame header. The frame header fields represent the frame as passed to the encoder, but not necessarily the exact values as they will be encoded file format: the encoder could change crop and blending options of a frame for more efficient encoding or introduce additional internal frames. Animation duration and time code information is not altered since those are immutable metadata of the frame.
- JxlEncoder
SetFrame ⚠Lossless - Enables lossless encoding.
- JxlEncoder
SetFrame ⚠Name - Sets the name of the animation frame. This function is optional, frames are
not required to have a name. This setting is a part of the frame header, and
the same principles as for
JxlEncoderSetFrameHeaderapply. Thename_lengthfield ofJxlFrameHeaderis ignored by the encoder, this function determines the name length instead as the length in bytes of the C string. - JxlEncoder
SetICC ⚠Profile - Sets the original color encoding of the image encoded by this encoder as an
ICC color profile. This is an alternative to
JxlEncoderSetColorEncodingand only one of these two must be used. This one sets the color encoding as ICC binary data, while the other defines it as aJxlColorEncoding. Must be called afterJxlEncoderSetBasicInfo. - JxlEncoder
SetOutput ⚠Processor - Sets the output processor for the encoder. This processor determines how the encoder will handle buffering, writing, seeking (if supported), and setting a finalized position during the encoding process.
- JxlEncoder
SetParallel ⚠Runner - Set the parallel runner for multithreading. May only be set before starting encoding.
- JxlEncoder
SetUpsampling ⚠Mode - Sets the upsampling method the decoder will use in case there are frames
with
JxlEncoderFrameSettingsSetOptionset. This is useful in combination with theJxlEncoderFrameSettingsSetOptionoption, to control the type of upsampling that will be used. - JxlEncoder
StoreJPEG ⚠Metadata - Configure the encoder to store JPEG reconstruction metadata in the JPEG XL container.
- JxlEncoder
UseBoxes ⚠ - Indicates the intention to add metadata boxes. This allows
JxlEncoderAddBoxto be used. When using this function, then it is required to useJxlEncoderCloseBoxesat the end. - JxlEncoder
UseContainer ⚠ - Forces the encoder to use the box-based container format (BMFF) even when not necessary.
- JxlEncoder
Version ⚠ - Encoder library version.
Type Aliases§
- JxlDebug
Image Callback - Function type for
JxlEncoderSetDebugImageCallback.