If anyone's curious why I'm always doing the little #LossyPNG dance, it's because you can get some crazy good compression sacrificing color depth, instead of using a traditional lossy algorithm which gives you good compression by sacrificing detail:

tmp $ ll kate* -rw-rw-r-- 1 rld rld 124,117 Feb 23 12:51 kate-kwrite1.png -rw-rw-r-- 1 rld rld 23,710 Feb 23 12:51 kate-kwrite2.png -rw-rw-r-- 1 rld rld 19,936 Feb 23 12:54 kate-kwrite3.png -rw-rw-r-- 1 rld rld 18,572 Feb 23 12:55 kate-kwrite4.png 186335 total tmp $ colors kate* kate-kwrite1.png (unknown) kate-kwrite2.png 16 kate-kwrite3.png 9 kate-kwrite4.png 8

(kate-kwrite1.png was the original (truecolor) screenshot)
(kate-kwrite2.png was automatically reduced to 16 colors by ImageMagic)
(kate-kwrite3.png was reduced to 9 colors by hand-picking dominant colors in GIMP)
(kate-kwrite4.png was reduced to 8 colors by hand-picking dominant colors in GIMP)

@rl_dane
Or just use https://tinypng.com/
It's much faster :)
TinyPNG – Compress AVIF, WebP, PNG and JPEG images

Free online image optimizer for faster websites! Reduce the file size of your AVIF, WEBP, JPEG and PNG images while preserving the image quality.

@amarok

That dropped it down to 46KB, which is impressive, especially since it reduced it to 256 colors in a way that's not noticeable, but I can get much smaller sizes by reducing the colors even further.

I do wonder what else it's doing, as it gets better compression than imagemagick does when reducing to 256 colors:

124,117 original 23,710 ImageMagick 16 colors 19,936 GIMP 9 colors 18,572 GIMP 8 colors 40,803 ImageMagick 64 colors 51,271 ImageMagick 256 colors 46,918 tinypng.com

@amarok

I did some more testing. I tried using GIMP to reduce to 256 colors using all four of their dithering options (none, ordered, floyd-steinberg, floyd-steinberg reduced color bleeding)

The only dithering options in GIMP that produced a smaller image was none and ordered, so that website has some kind of secret sauce that makes it a little better than GIMP, but I can still get it smaller with a little elbow grease. ;)

@rl_dane
I use TinyPNG just to save time, it's fast and gives good results. You can even squeeze a few more percent when feeding TinyPNG with the result again. But I would prefer GIMP and other tools if I wanted perfect control over the palette, so I agree with you.

@amarok

Just FYI, I was able to get within 4.1% of the size of TinyPNG (and close to the same quality) just using:

convert input.png -colors 256 output.png

You just need imagemagick installed and Bob's your uncle. ;)

You can even script/batch it. It's pretty cool. GIMP gives better results, of course, but imagmagick is crazy convenient.