posva / catimg

🦦 Insanely fast image printing in your terminal
http://posva.net/shell/retro/bash/2013/05/27/catimg
MIT License
1.38k stars 57 forks source link

24-bit colors vs Unicode should be orthogonal #23

Closed kilobyte closed 7 years ago

kilobyte commented 7 years ago

For some reason, you assume 24-bit color codes are available when in Unicode mode, and 256 color otherwise. These capabilities are completely unrelated.

Not all terminals support 24-bit colors (https://gist.github.com/XVilka/8346728 -- non-fringe ones are Putty, Terminology and aterm; silently downconverting as xterm does is acceptable).

Non-Unicode is nearly extinct.

Too bad, neither of those imply the other.

posva commented 7 years ago

Hey thanks for letting me know. It seems not to exist a way to detect it yet, though. So what do you recommend?

posva commented 7 years ago

Closing due to inactivity

kilobyte commented 7 years ago

Sadly, I found no way to reliably detect 24-bit support. Only two libraries provide such a way: newer versions of libvte set an env var VTE_VERSION, Konsole produces four: KONSOLE_DBUS_SERVICE, KONSOLE_DBUS_SESSION, KONSOLE_DBUS_WINDOW, KONSOLE_PROFILE_NAME.

Because of a terrible misdesign, printing 24-bit codes results in garbage if not supported: ANSI codes are supposed to be safely ignorable when not supported, but T416 where 256/24-bit/CMY/CMYK comes from disregarded these principles.

Thus, I'm afraid defaulting to 24-bit is a bad idea, at least until terminals themselves are fixed. And a number of them declared 24-bit support as WONTFIX.