← All projects

C++17 · Zero dependencies

lightpress

A zero-dependency C++17 image-compression and media-container library. JPEG and PNG codecs written from scratch, metadata stripping at the byte level, quality-preserving resize, and MP4/MOV container rewriting — nothing beyond the C++17 standard library.

no third-party deps AAN fast DCT DEFLATE / CRC32 SSIM-validated

Why build a codec from scratch

lightpress was born from a real constraint: iMessage Exporter Redux needed to compress exported attachments before archiving them, but pulling in libjpeg, libpng, and an ffmpeg dependency tree for that would have bloated a tool meant to ship as a single clean binary. So I wrote the codec instead — portable C++17, no external libraries, fully under my control.

What it does

CapabilityDetails
JPEG encodeAAN fast DCT, BT.601 YCbCr, 4:2:0 chroma subsampling, IJG quality scaling, standard Huffman tables, JFIF container
JPEG decodeBaseline decoder for roundtrip testing and SSIM calculation
PNG encodeOptimal per-scanline filter selection, DEFLATE with fixed Huffman, CRC32, full IHDR/IDAT/IEND chunking
PNG decodeFilter reversal + inflate; RGB, RGBA and grayscale (color types 0/2/6)
EXIF stripRemoves APP1 (EXIF/XMP), APP2 (ICC), APP13 (IPTC) from JPEG at the marker level — no re-encode, no quality loss
ResizeNearest-neighbour, bilinear, and bicubic (Mitchell–Netravali) with sRGB linearization
MP4 / MOV stripWalks the MPEG-4 Part 12 atom tree, removes udta/meta/cover-art atoms, and rewrites size fields

Honest about its limits

Part of building good systems software is being precise about what it doesn't do. lightpress says so in its own README:

Validated, not just written

A from-scratch codec is only useful if its output is genuinely good. lightpress uses SSIM (structural similarity) to benchmark its encodes against ffmpeg baselines, with a built-in decoder so every encode can be measured on roundtrip. The test suite runs under CTest.

cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure
← Back to all projects