# HTJ2K Rust

Canonical page: https://frames-sg.com/j2k/htj2k-rust/

The `j2k` crate provides safe Rust APIs for JPEG 2000 Part 15 HTJ2K codestream decoding, encoding, recoding, and JPH still-image wrapping. The `j2k-transcode` crate provides coefficient-domain JPEG-to-HTJ2K transcode primitives for supported baseline JPEG inputs. Apple Metal and NVIDIA CUDA accelerate supported routes.

## Features

- **Decode and encode:** Raw HT codestreams and JPH still-image files, including cleanup and refinement packet routes.
- **Recode:** Classic JPEG 2000 inputs use coefficient-domain recoding where valid, with a pixel-preserving fallback for signed, high-bit, lossy, sampled, and other incompatible coefficient-domain cases.
- **Transcode:** Supported baseline JPEG inputs can be transformed to HTJ2K from DCT coefficients through `j2k-transcode`; Metal and CUDA crates accelerate supported transform stages.
- **Part 15 coding:** HT cleanup, significance-propagation refinement, magnitude refinement, packet-length signaling, and quality-layer contributions are covered by repository tests.
- **JPH files:** JPH inspection and wrapping reuse the JP2 box parser and validate HT codestream branding.

HTJ2K requests above the Part 15 coded-bitplane limit return an error. Reference codecs may be used for benchmark comparison but are not runtime fallbacks.

## Install and resources

```sh
cargo add j2k
cargo add j2k-transcode
```

- [Exact support matrix](https://github.com/frames-sg/j2k/blob/main/docs/public-support.md)
- [J2K API documentation](https://docs.rs/j2k)
- [Transcode API documentation](https://docs.rs/j2k-transcode)
- [Source repository](https://github.com/frames-sg/j2k)
