justjp2
Pure Rust JPEG 2000 (JP2/J2K) encoder and decoder.
Features
- Encode/Decode JP2 file format and raw J2K codestreams
- Lossless (5/3 DWT + RCT) and lossy (9/7 DWT + ICT) compression
- Multi-tile support with parallel encoding via rayon
- Reduce resolution decoding (decode at lower resolution levels)
- Region of interest decoding (crop to a specific area)
- Format auto-detection (JP2 vs J2K)
- No unsafe code, no C dependencies
Quick Start
use ;
// Encode
let image = Image ;
let params = default; // lossless JP2
let bytes = encode.unwrap;
// Decode
let decoded = decode.unwrap;
assert_eq!;
Supported Formats
| Format | Extension | Encode | Decode |
|---|---|---|---|
| JP2 | .jp2 |
Yes | Yes |
| J2K | .j2k |
Yes | Yes |
API
// Decode (auto-detects JP2 vs J2K)
decode // Decode at reduced resolution
decode_with_reduce // Decode a specific region
decode_region // Encode
encode
Architecture
Built from the ground up following ITU-T T.800 (JPEG 2000 Part 1):
| Module | Description |
|---|---|
bio |
Bit-level I/O with 0xFF bit-stuffing |
tgt |
Tag tree encoder/decoder |
mqc |
MQ arithmetic coder (47-state context model) |
t1 |
Tier-1 EBCOT block coder (sig/ref/cleanup passes) |
dwt |
Discrete Wavelet Transform (5/3 reversible, 9/7 irreversible) |
mct |
Multi-Component Transform (RCT/ICT color transforms) |
quantize |
Scalar quantization with DWT/MCT norm tables |
t2 |
Tier-2 packet assembly |
pi |
Packet iterator (LRCP, RLCP, RPCL, PCRL, CPRL) |
tcd |
Tile coder/decoder pipeline |
marker |
J2K marker segment parsing |
j2k |
J2K codestream codec |
jp2_box |
JP2 box format parser |
jp2 |
JP2 file format codec |
License
Apache-2.0