color quantization, reduce the number of colors (PNG)

last modified on 9 July 2019, by Cédric Louvrier

pingo could pre-process the image data from PNG using a fast filter. this lossy transformation, which reduce the number of colors, could be more effective using high quality presets (80+) on RGBA samples

N: from 1 to 100 — 1: smaller filesize, worse quality — 100: bigger filesize, better quality
pingo -pngcolor=N target

color quantization

original file: palette-colours.png (71.03 KB): PNG color quantization
original pingo -pngcolor=100 pingo -pngcolor=90
palette colours - original palette colours - pngfilter 100 palette colours - pngfilter 90
71.03 KB — 15359 colors 60.21 KB (0.11s) — 9657 colors 59.09 KB (0.12s) — 9262 colors
dssim - butteraugli 0.00003171 — 0.564144 0.00003431 — 0.546544
pingo -pngcolor=80 pingo -pngcolor=70 pingo -pngcolor=60
palette colours - pngfilter 80 palette colours - pngfilter 70 palette colours - pngfilter 60
53.50 KB (0.10s) — 7295 colors 52.52 KB (0.11s) — 6846 colors 50.43 KB (0.10s) — 6265 colors
0.00008912 — 0.862572 0.00009161 — 0.862658 0.00014487 — 1.179962
pingo -pngcolor=50 pingo -pngcolor=40 pingo -pngcolor=30
palette colours - pngfilter 50 palette colours - pngfilter 40 palette colours - pngfilter 30
49.11 KB (0.09s) — 5781 colors 46.41 KB (0.12s) — 4911 colors 45.23 KB (0.11s) — 4364 colors
0.00014733 — 1.179962 0.00022151 — 1.429802 0.00032659 — 1.732856
pingo -pngcolor=20 pingo -pngcolor=10 pingo -pngcolor=1
palette colours - pngfilter 20 palette colours - pngfilter 10 palette colours - pngfilter 1
43.66 KB (0.10s) — 3959 colors 42.38 KB (0.10s) — 3649 colors 41.37 KB (0.11s) — 3382 colors
0.00046640 — 1.744140 0.00053934 — 2.322941 0.00076611 — 2.533867

compression level

note that the lossless compression level over this transformation can be increased to get smaller filesize by using -sN

N: from 0 to 9 — 0: fast and good compression — 9: slow, but better compression
pingo -pngcolor -sN target