Graphics Protocols

Neofetch showcase

All three inline-image protocols support both encoding (write to a terminal) and decoding (receive from a PTY). When kou's Screen encounters an inline-image escape sequence, it decodes the image and stores it; the renderer overlays each placement using contain-fit (aspect ratio preserved).

ProtocolDirectionFormatTerminals
Kitty2 (APC)Encode + Decodebase64 PNGkitty, wezterm, Ghostty
iTerm2 (OSC 1337)Encode + Decodebase64 PNGiTerm2, wezterm
Sixel (DCS)Encode + DecodeRaster languagexterm, mlterm, mintty

Sixel encoding/decoding uses the icy_sixel crate (pure Rust, behind the sixel cargo feature).

Rainbow gradient

Driving it

use kou::{FontCache, FontSet, GraphicsProtocol, VttyManager, render_graphics, theme_by_name};

let screen = mgr.screen(&id).await?;
let fonts = FontCache::load(&FontSet::from_env(), 16.0);
let theme = theme_by_name("campbell");
if let Some(escape) = render_graphics(&screen, &fonts, 16.0, GraphicsProtocol::from_env(), theme) {
    print!("{escape}");
} else {
    let png = kou::render_png(&screen, &fonts, 16.0, theme)?;
    std::fs::write("screen.png", png)?;
}