Skip to main content

jxl_encoder/
lib.rs

1// Copyright (c) Imazen LLC and the JPEG XL Project Authors.
2// Algorithms and constants derived from libjxl (BSD-3-Clause).
3// Licensed under AGPL-3.0-or-later. Commercial licenses at https://www.imazen.io/pricing
4
5//! JPEG XL encoder in pure Rust.
6//!
7//! This crate provides a complete JPEG XL encoder implementation, supporting
8//! both lossless (modular) and lossy (VarDCT) encoding modes.
9
10#![forbid(unsafe_code)]
11
12extern crate alloc;
13
14pub mod api;
15pub mod bit_writer;
16pub mod color;
17pub mod container;
18pub mod entropy_coding;
19pub mod error;
20pub mod headers;
21pub(crate) mod icc;
22pub mod image;
23#[cfg(feature = "jpeg-reencoding")]
24pub mod jpeg;
25pub mod modular;
26pub mod trace;
27pub mod vardct;
28
29// Re-export new API as primary
30pub use api::{
31    AnimationFrame, AnimationParams, At, EncodeError, EncodeMode, EncodeRequest, EncodeResult,
32    EncodeStats, ImageMetadata, Limits, LosslessConfig, LossyConfig, Lz77Method, PixelLayout,
33    Quality, ResultAtExt, Stop, Unstoppable, at,
34};
35
36/// Group dimension in pixels (256x256 groups).
37pub const GROUP_DIM: usize = 256;
38
39/// DCT block dimension (8x8 blocks).
40pub const BLOCK_DIM: usize = 8;
41
42/// Size of a single DCT block (64 coefficients).
43pub const BLOCK_SIZE: usize = BLOCK_DIM * BLOCK_DIM;
44
45/// JXL signature bytes.
46pub const JXL_SIGNATURE: [u8; 2] = [0xFF, 0x0A];
47
48#[cfg(test)]
49pub mod test_helpers;
50
51#[cfg(test)]
52mod tests;
53
54#[cfg(test)]
55#[path = "api_tests.rs"]
56mod api_tests;