OzzyMitchell/tinycodec

A lossless codec in 71 lines of C code.

C

0

4 commits

updated Oct 4, 2026

See the code

See what people are saying

SourceMessageScoreDate

Show HN: Lines of C, Beats QOI

1

Oct 4, 2026

README

TinyCodec

A lossless codec in 45 lines of C code.

CLI

To use the CLI, use pack to encode an image and unpack to decode it into a PNG.

tcom pack image.png
tcom unpack image.tcom

The CLI in tcom_dependency.c supports PNG, BMP, PNM/PAM, QOI and WebP.

The codec itself is 45 lines. The CLI and format adapter is 164 lines, minus the image libraries.

Benchmark

3,167 images. Combined file sizes and encoding/decoding speeds:

CodecTotal size (MB)Encode (MP/s)Decode (MP/s)
TCOM1,954.35284.09368.18
QOI2,125.45238.71298.07
libpng level 61,792.597.30100.16
Oxipng effort 41,621.251.14113.90

MB is decimal and MP/s is million pixels per second.

This was done on a 9950x3d, measured in memory without file I/O and all decoded pixels matched as they should.

Copyright 2026 Ozzy M. Licensed under Apache 2.0.

Third-party code retains their own licenses of course.

OzzyMitchell/tinycodec

A lossless codec in 71 lines of C code.

C

0

4 commits

updated Oct 4, 2026

See the code

See what people are saying

SourceMessageScoreDate

Show HN: Lines of C, Beats QOI

1

Oct 4, 2026

README

TinyCodec

A lossless codec in 45 lines of C code.

CLI

To use the CLI, use pack to encode an image and unpack to decode it into a PNG.

tcom pack image.png
tcom unpack image.tcom

The CLI in tcom_dependency.c supports PNG, BMP, PNM/PAM, QOI and WebP.

The codec itself is 45 lines. The CLI and format adapter is 164 lines, minus the image libraries.

Benchmark

3,167 images. Combined file sizes and encoding/decoding speeds:

CodecTotal size (MB)Encode (MP/s)Decode (MP/s)
TCOM1,954.35284.09368.18
QOI2,125.45238.71298.07
libpng level 61,792.597.30100.16
Oxipng effort 41,621.251.14113.90

MB is decimal and MP/s is million pixels per second.

This was done on a 9950x3d, measured in memory without file I/O and all decoded pixels matched as they should.

Copyright 2026 Ozzy M. Licensed under Apache 2.0.

Third-party code retains their own licenses of course.

Languages

C

96.7%

CMake

3.3%