With existing choices of the old text mode standby and its friend, the most unreasonably efficient sixel encoder known to man, I threw Kitty and iTerm2 on the pile, bringing our total number of output formats to four. I think that's all the terminal graphics anyone could want (unless you want ReGIS; in which case, tough tty).
Modern terminal emulators are generally less fickle than their pre-y2k ancestors. However, sometimes it takes a little sleuthing to figure out which extended features might be hiding behind e.g. some mysterious
xterm-256color façade so we can do the right thing.
Luckily, Chafa has a steadily improving handle on terminals of the Unix/GNU/Linux world. A few examples:
- VTE-based terminals (there are many, including GNOME Terminal).
- Sixel crew: foot, mlterm, WezTerm, XTerm.
- A category unto its own: Kitty, packing one of the most featureful terminal graphics protocols around.
- Another innovative beast of genetically engineered goodness: ctx.
- Fullscreen consoles: fbterm (quirky!), yaft (yet more sixels!) and the Linux console.
- Simple and sweet: st, urxvt.
- For the Mac addicts: Apple Terminal, iTerm2.
- Sessions running in screen and tmux.
Of course, this is forever a work in progress and an area where I receive regular, highly appreciated contributions *chef's kiss – somehow still not an actual emoji*.
Funky lo-fi features
Øyvind Kolås (of GIMP and GEGL fame) swooped in with new builtins for the legacy computing block, meaning Chafa is now PETSCII Ready™ – or as ready as you can be with Unicode 13.0: The standard has a few annoying issues, such as not declaring any code points for the four permutations of black triangle, relying instead on existing code points in the geometric shapes block (U+25E2..U+25E5) which are typically represented by fonts as sitting on the baseline surrounded by empty space and therefore useless next to the legacy computing and block elements blocks.
Still, it's got a sweet 2×3 dot matrix (
--symbols sextant) and all those nifty wedge shapes (
Øyvind also added an 8-color mode. Used together (
-c 8 --symbols legacy+space), these features enable visual emulation of Teletext Level 1 and similar systems widely deployed in the late 1970s until roughly 1990 (technically into the present, albeit perhaps not so widely anymore).
Somewhere along the way I discovered that Øyvind has a Patreon page – and if you're a GIMP user and/or care about the free software graphics ecosystem, you may want to read this article and consider its implications.
A bit of background austerity
I followed up in the retro vein with a foreground-only (
--fg-only) modifier, which allows emulation of vintage systems that could only specify a single color per cell against a uniform background color. A popular example is the Commodore 64's standard character mode. It's also useful in terminals where block symbols don't render correctly (for example due to missing font support), since it prevents background color variation from drowning out details in low-coverage symbols used in their place. The Linux console tends to be among these due to hardware and font limitations that are somehow still in play today.
This is also how many classic ASCII art packages did things; so I guess I am once again asking you to party like it's 1999 (…and stay up all night trying to make your Napster killer render with AAlib).
When used with
--fg-only, the existing
--bg option has a greater impact than usual; in addition to being the fade color for alpha blending, it determines the relationship between symbols and blank space, including symbols where the background color "wins" part of a cell. A dark image on a bright background will have more high-coverage symbols that cover up the background as much as possible.
If your terminal has a bright background color,
--invert is a shortcut to inverting the sense of
--bg; the white-on-black default then becomes black-on-white.
Since foreground-only mode leaves the background color alone, you can easily experiment with setting it yourself, e.g:
echo -e '\033[41m'; \ chafa -c 16 --symbols ascii --fg-only --bg darkred birbs.png
Weird and wonderful forum art redux
If you read Steam reviews, you may be familiar with this guy:
There are layers to this, but I'll keep it brief and simply observe that people seem to like braille. Braille is popular in this context for at least four reasons. It has:
- A luxurious 2×4 dot matrix at your fingertips.
- Widespread font support.
- Consistent glyph width even in variable-width fonts.
- A special blank symbol (U+2800 BRAILLE PATTERN BLANK) for consistent spacing.
Chafa's supported this kind of output for a long time (
-c none --symbols braille), but in some circumstances it could replace cells having identical foreground and background colors with a hardcoded U+0020 as an optimization. This could result in inconsistent spacing, making braille (and probably other symbol combinations) less useful. Fortunately the issue is now a thing of the past; the latest version will instead use a visually blank symbol from the user's symbol set, falling back to the lowest-coverage symbol it can find.
The GPL doesn't regulate netiquette: Please use for good, or in extreme cases, awesome.
The ever elusive practical application in the wild