otf-pixels-codec-jpeg
JPEG for Pixels, baseline written from scratch
An Open Tech Foundation project
Baseline JPEG decode and encode, streaming one MCU row at a time. Decoding at 1/2, 1/4 or 1/8 scale makes thumbnails of large photos cheap.
[!TIP] Building an app or a server? Use
otf-pixelsinstead: it picks this codec from the file's bytes with itsjpegfeature.
Use it
Transcode row by row, without holding the image:
use ;
use ;
use ;
let file = open?;
let mut decoder = with_scale?;
let descriptor = decoder.descriptor;
let mut encoder = with_quality?.with_subsampling;
let mut out = Vecnew;
encoder.write_header?;
let mut row = vec!;
for _ in 0..descriptor.height
encoder.finish?;
Capabilities
| Area | Support |
|---|---|
| Decode | Baseline 8-bit, standard chroma subsampling; scaled 1/2, 1/4, 1/8 |
| Progressive | Decode behind the progressive feature (on by default), via jpeg-decoder |
| Encode | Baseline, quality 1–100, chroma subsampling none / horizontal / both |
| Checked against | libjpeg, both directions |
API
| Item | What it does |
|---|---|
JpegDecoder |
Decoder; new, with_scale |
JpegEncoder, Subsampling |
Encoder and its chroma option |
Scale |
Reduced-size decode |
JpegCodec, probe |
Signature detection |
Part of Pixels
| Crate | Role |
|---|---|
otf-pixels |
The chainable Image API most users want |
otf-pixels-core |
Graph, tiles, scheduler, codec and op traits |
otf-pixels-ops |
Image operations |
otf-pixels-compress |
DEFLATE, zlib, LZW, checksums |
otf-pixels-codec-* |
One crate per format |
License
Apache-2.0 — see LICENSE.