View Full Version : Small Wavelet Thumbnail & Preview Codec - WTPC


lieff
7th August 2026, 22:35
Hi)
Here new stb_image-like codec. It targets low sizes from 200 B to 36 KB at resolutions around 256x256, but supports any image dimensions up to 65536x65536. The main target for thumbnails is 1400 B, designed to fit within one MTU packet, so the user sees something while the main preview downloads.
It also supports thumbhash-like mode for 30-50B size.
Competitive with heavy codecs live avif and BPG by speed\quality.

Codec and more comparison details here https://github.com/lieff/miniwtpc

nhw_pulsar
8th August 2026, 06:58
Hello,

Wow, I have (rapidly) tested WTPC on 5 of my (512x512) test images, and your codec is excellent! -And in general, not only for thumbnail.-

Certainly the greatest precision of the wavelet codecs I could test.

Great work.

Cheers,
Raphael

LMP88959
8th August 2026, 14:24
Very cool project, nice work! How did you design it?

lieff
8th August 2026, 15:11
Hello,

Wow, I have (rapidly) tested WTPC on 5 of my (512x512) test images, and your codec is excellent! -And in general, not only for thumbnail.-

Certainly the greatest precision of the wavelet codecs I could test.

Great work.

Cheers,
Raphael

Thanks)

lieff
8th August 2026, 15:17
Very cool project, nice work! How did you design it?

I originally created it for a mini-chat app, and want to create light-jpeg2000.
I do not expect to beat it at all, just get rid of heavy dependency.
Then you can check on commits (especially enchantment\optimizatios\tune) how quality grows up while implementing new ideas.

LMP88959
8th August 2026, 19:53
That's awesome that you developed a piece of tech to fit your needs. I saw some of the tuning software, is this something manual that would ideally be done for a certain set of image content? Similar to a trained codebook in the context of vector quantization.

lieff
8th August 2026, 20:32
That's awesome that you developed a piece of tech to fit your needs. I saw some of the tuning software, is this something manual that would ideally be done for a certain set of image content? Similar to a trained codebook in the context of vector quantization.

Yes, codec tuned on image dataset of ~3000 imags.
Core of this dataset is 1000 images from https://github.com/EliSchwartz/imagenet-sample-images, it's valuable because it's one per image-net class (1,000 object categories for its standard image classification challenge (ILSVRC)).
Rest is mix of other datasets. It's relatively small, AI trained on much larger datasets, but I have limited resources (one round takes around 2 days).
I tried craft small but representative dataset which represent averaged image on the internet, so you do not need re-train in yourself.
You can do it though if your images different from average.

LMP88959
9th August 2026, 00:18
Oh awesome, that's clever. Are you possibly going to have something like variance-adaptive-quantization in your codec? I know it's not really something that would benefit your use-case but I think it's interesting considering most wavelet codecs do not do it.

Z2697
9th August 2026, 07:01
I think with 9962390f the colors are off with no noticeable imrpovement. (from the example shown in readme)

lieff
9th August 2026, 11:26
Oh awesome, that's clever. Are you possibly going to have something like variance-adaptive-quantization in your codec? I know it's not really something that would benefit your use-case but I think it's interesting considering most wavelet codecs do not do it.

I've tried that, with no noticeable improvemеnt and more `ifs` in hot loop, so no luck with that currently.

lieff
9th August 2026, 11:33
I think with 9962390f the colors are off with no noticeable imrpovement. (from the example shown in readme)

Most noticeable imrpovement on this vector:

wallhaven-ogy7ql_256.png

19200

Space artefacts almost gone.
It's not final version, currently working on this.

Z2697
9th August 2026, 22:05
I've tried that, with no noticeable improvemеnt and more `ifs` in hot loop, so no luck with that currently.

It is a massive improvement for DCT based codec, maybe wavelet just doesn't work quite the same.

LMP88959
9th August 2026, 22:07
It is a massive improvement for DCT based codec, maybe wavelet just doesn't work quite the same.

It does greatly help with wavelets as well, though the metric needed to be modified a bit. I find it very effective in my codec.

lieff
9th August 2026, 22:41
I can give it another try then, later. Maybe I was doing it wrong.

nhw_pulsar
12th August 2026, 18:13
Hello,

I tested JPEG2000 years ago, but it really seems that WTPC is "very" visually better than JPEG2000. Could you argument where it comes from especially that WTPC only uses an EBCOT-lite scheme?

Does it come from a better context modeling of EBCOT and bitplanes?

Cheers,
Raphael

lieff
12th August 2026, 19:49
Hello,

I tested JPEG2000 years ago, but it really seems that WTPC is "very" visually better than JPEG2000. Could you argument where it comes from especially that WTPC only uses an EBCOT-lite scheme?

Does it come from a better context modeling of EBCOT and bitplanes?

Cheers,
Raphael

Hi) There many differences:
1. Per-subband quant tables.
2. Non-standard CDF 9/7 wavelet.
3. More rich contexts, cross-channel significance context.
4. Tuned prions for contexts.
5. Quality dependent prions.
6. Separate DC encoding.
7. Empty subbands skip.
8. Tuned with ssimulacra2 which do not exists when jp2k created.

nhw_pulsar
12th August 2026, 20:31
Hi) There many differences:
1. Per-subband quant tables.
2. Non-standard CDF 9/7 wavelet.
3. More rich contexts, cross-channel significance context.
4. Tuned prions for contexts.
5. Quality dependent prions.
6. Separate DC encoding.
7. Empty subbands skip.
8. Tuned with ssimulacra2 which do not exists when jp2k created.

Ok, great!

lieff
14th August 2026, 19:00
What is better, this:

19204

19205

Chroma from ship leaked far away. ~36 B mean

Or this:

19206

19207

Lena now have less vivid blue hair color, but chroma now can`t leak far away. ~37 B mean.

Z2697
14th August 2026, 20:26
I think the "less chroma leak" is better, but real problem is the greenish tint with the other one.
Also the blurring looks blocky, I think it's a bit annoying.

lieff
14th August 2026, 21:03
Now new variant is less green:

19208

Blocky blur can`t be fixed without changing CDF 9/7 wavelet.