JPEG 2000and HTJ2K

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.

View j2k-core downloads on crates.io

What J2K provides

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.

GPU acceleration

Applications keep a portable CPU path and can send supported workloads to Apple Metal or NVIDIA CUDA.

MIT or Apache-2.0

The workspace is dual-licensed for use in open-source and commercial projects.

How J2K runs

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.

J2K libraries handle JPEG 2000 and HTJ2K. Separate JPEG and transcode crates handle ordinary JPEG, with Apple Metal, NVIDIA CUDA and CPU execution.
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.

Supported formats

Exact coverage is maintained in the public support matrix.

In scope

JPEG 2000 Part 1

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.

In scope

HTJ2K Part 15

HT cleanup and refinement decode/encode, quality layers, rate behavior, raw HT codestreams, and JPH still-image wrapping are in scope.

Limits

Wrappers and limits

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.

Install

Most applications should start with the public facade crate. The CLI is useful for inspection and conservative JPEG-to-HTJ2K transcode smoke tests.

Library
$ cargo add j2k

Safe public APIs for inspection, decode, encode, recode, JP2, and JPH.

CLI smoke test
$ cargo install j2k-cli
$ j2k inspect input.jp2
$ j2k transcode input.jpg output.j2k \
    --htj2k --lossless-53

Package map

CrateRoleLayer
j2kPublic API for JPEG 2000 Part 1 / HTJ2K Part 15 inspection, decode, encode, recode, JP2, and JPH.Public
j2k-metalApple Metal acceleration for supported macOS GPU paths.GPU
j2k-cudaNVIDIA CUDA acceleration for supported JPEG 2000 and HTJ2K paths.GPU
j2k-transcodeJPEG-to-HTJ2K coefficient-domain transcode primitives and shared transcode contracts.Core
j2k-jpegJPEG decode, strict about pixel integrity by default, and encode, plus dense RGB8 batch decode.Public
j2k-mlBurn tensors from JPEG 2000 batches, or mixed JPEG and JPEG 2000 batches on the CPU.Integration
j2k-pythonPyTorch/NumPy extension, built as the j2k wheel, with CPU output and optional CUDA or Apple Silicon MPS output.Integration
j2k-cliCommand-line inspection and JPEG-to-HTJ2K transcode smoke tests.Tool

Topic pages