Modules / Standard library
std/jpeg
Baseline and progressive JPEG files to and from std/image pictures, on every target: JFIF writing with 4:2:0 chroma subsampling, standard Huffman tables and the IJG quality scale that libjpeg and Pillow use; reading accepts baseline (SOF0/SOF1) and progressive (SOF2) greyscale and YCbCr JPEGs. bytes: Vec(u8) if WriteJPEG(*title, *bytes, 82) { WriteEntireFile("title.jpg", BuilderFinish(bytes)) } decoded := ReadJPEG(VecSlice(bytes, 0, bytes.count))
Stable Shipped in release v0.7.0.
Import with #import "std/jpeg".
WriteJPEG :: (image: *Image, output: *Vec(u8), quality: s32) -> boolAppends IMAGE as a baseline JPEG at QUALITY (1 to 100) to OUTPUT.
ReadJPEG :: (bytes: []u8) -> ImageDecodes a baseline or progressive JPEG file's bytes (1-channel greyscale or 3-channel YCbCr with any standard chroma subsampling) into an Image. Returns an invalid Image (see ImageValid) when BYTES is not a supported JPEG.
Source ↗ · All modules