Safe public Rust APIs
Applications use a safe Rust API. Unsafe implementation code is limited to documented FFI, GPU, SIMD, allocation, and pointer or buffer boundaries.
Safe public Rust APIs for JPEG 2000 Part 1 and HTJ2K Part 15 inspection, decode, encode, recode, and coefficient-domain JPEG-to-HTJ2K transcode workflows.
Apple Metal and NVIDIA CUDA accelerate supported operations. CPU implementations are also available.
Release statusSee the changelog and crates.io for the current published version.
Public surface
Applications use a safe Rust API. Unsafe implementation code is limited to documented FFI, GPU, SIMD, allocation, and pointer or buffer boundaries.
Applications keep a portable CPU path and can send supported workloads to Apple Metal or NVIDIA CUDA.
The workspace is dual-licensed for use in open-source and commercial projects.
Architecture
The j2k crate handles JPEG 2000 and HTJ2K still images. Separate j2k-jpeg and j2k-transcode crates handle ordinary JPEG and JPEG-to-HTJ2K conversion. Apple Metal and NVIDIA CUDA accelerate supported operations.
Auto returns CPU output when no GPU path is available, supported, or measured faster for the shape. Explicit Metal and CUDA requests never fall back.Exact coverage is maintained in the public support matrix.
Raw J2K/J2C codestream parse, inspect, decode, encode, ROI, progression, tile-part, packet-marker, signed, high-bit, and component-plane surfaces are tracked by the public support matrix.
HT cleanup and refinement decode/encode, quality layers, rate behavior, raw HT codestreams, and JPH still-image wrapping are in scope.
JP2 and JPH still-image metadata is supported. JPX / JPEG 2000 Part 2 extensions are not.
The full support table is in docs/public-support.md. Benchmark results are in docs/benchmark-evidence.md; comparisons with other codecs use pinned external corpora.
Most applications should start with the public facade crate. The CLI is useful for inspection and conservative JPEG-to-HTJ2K transcode smoke tests.
$ cargo add j2k
Safe public APIs for inspection, decode, encode, recode, JP2, and JPH.
$ cargo install j2k-cli $ j2k inspect input.jp2 $ j2k transcode input.jpg output.j2k \ --htj2k --lossless-53
Workspace
| Crate | Role | Layer |
|---|---|---|
j2k | Public API for JPEG 2000 Part 1 / HTJ2K Part 15 inspection, decode, encode, recode, JP2, and JPH. | Public |
j2k-metal | Apple Metal acceleration for supported macOS GPU paths. | GPU |
j2k-cuda | NVIDIA CUDA acceleration for supported JPEG 2000 and HTJ2K paths. | GPU |
j2k-transcode | JPEG-to-HTJ2K coefficient-domain transcode primitives and shared transcode contracts. | Core |
j2k-jpeg | JPEG decode, strict about pixel integrity by default, and encode, plus dense RGB8 batch decode. | Public |
j2k-ml | Burn tensors from JPEG 2000 batches, or mixed JPEG and JPEG 2000 batches on the CPU. | Integration |
j2k-python | PyTorch/NumPy extension, built as the j2k wheel, with CPU output and optional CUDA or Apple Silicon MPS output. | Integration |
j2k-cli | Command-line inspection and JPEG-to-HTJ2K transcode smoke tests. | Tool |
Documentation