JPEG / Rust / CPU + GPU adapters

Rust JPEG Codec

j2k-jpeg is a pure-Rust JPEG inspection, decoding and encoding crate for general imaging, pathology, medical imaging and transcode pipelines.

JPEG primitives for real pipelines.

Use one crate for ordinary JPEG input, DICOM-oriented 12-bit and lossless variants, TIFF tile normalization and baseline encoding.

Decode

Whole images, crops and scaled output

Decode baseline, extended, progressive and lossless JPEG. Reduced IDCT paths provide one-half, one-quarter and one-eighth output for sequential and progressive DCT images.

Encode

Baseline, 12-bit and lossless

Encode 8-bit baseline JPEG, 12-bit extended sequential JPEG and lossless JPEG with predictors, point transforms and restart intervals. The crate writes codestreams; containers remain the caller’s responsibility.

Integrate

TIFF, DICOM and ICC metadata

Normalize abbreviated TIFF JPEG tiles with shared tables, repair zero-SOF dimensions from container metadata, and extract, insert or replace ordered APP2 ICC profile data.

Broad JPEG support. Clear rejection.

Decode

DCT JPEG 8- or 12-bit

Baseline, extended and progressive DCT coverage includes grayscale, YCbCr, RGB and Adobe CMYK/YCCK for supported sampling layouts.

Decode + encode

Lossless JPEG 2–16 bit

Predictors 1–7, point transforms, restart intervals and split scans are supported within the published format boundary.

Not supported

Explicit limits return errors

Arithmetic coding, hierarchical JPEG, four-component lossless JPEG and incompatible sampling layouts are rejected rather than guessed or silently converted.

Reference behaviorThe committed matrices compare supported decoded output with libjpeg-turbo and DICOM JPEG cases with DCMTK. See the crate README and source for the exact boundary.

Add JPEG to a Rust pipeline.

Use j2k-jpeg directly for JPEG. Use j2k for JPEG 2000 and HTJ2K, or j2k-transcode for supported JPEG-to-HTJ2K coefficient-domain workflows.

LibraryCPU baseline
$ cargo add j2k-jpeg

Safe Rust inspection, decode and encode APIs.

Related imaging routes