Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • About Bonfire
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
@rl_dane@polymaths.social  路  activity timestamp 3 days ago

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)

  • Copy link
  • Flag this post
  • Block
饾枂饾枓饾枂饾枟饾枖饾枑
饾枂饾枓饾枂饾枟饾枖饾枑
@amarok@mastodonczech.cz  路  activity timestamp 3 days ago

@rl_dane
Or just use https://tinypng.com/
It's much faster :)

  • Copy link
  • Flag this comment
  • Block
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
@rl_dane@polymaths.social  路  activity timestamp 3 days ago

@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
  • Copy link
  • Flag this comment
  • Block
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
@rl_dane@polymaths.social  路  activity timestamp 3 days ago

@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. ;)

  • Copy link
  • Flag this comment
  • Block
饾枂饾枓饾枂饾枟饾枖饾枑
饾枂饾枓饾枂饾枟饾枖饾枑
@amarok@mastodonczech.cz  路  activity timestamp 3 days ago

@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.

  • Copy link
  • Flag this comment
  • Block
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 馃嵉 :MiraLovesYou:
@rl_dane@polymaths.social  路  activity timestamp 3 days ago

@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.

  • Copy link
  • Flag this comment
  • Block

BT Free Social

BT Free is a non-profit organization founded by @ozoned@btfree.social . It's goal is for digital privacy rights, advocacy and consulting. This goal will be attained by hosting open platforms to allow others to seamlessly join the Fediverse on moderated instances or by helping others join the Fediverse.

BT Free Social: About 路 Code of conduct 路 Privacy 路
Bonfire social 路 1.0.2-alpha.34 no JS en
Automatic federation enabled
Log in
Instance logo
  • Explore
  • About
  • Code of Conduct