Skip to content

isene/glow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glow - Terminal Image Display

Rust License Platform Dependencies Stay Amazing

Display images inline in the terminal using kitty graphics protocol, sixel, or w3m. Auto-detects the best protocol for your terminal. Feature clone of termpix.

Used by pointer for file preview images.


Quick Start

[dependencies]
glow = { version = "0.1", path = "../glow" }
use glow::Display;

let mut display = Display::new();  // Auto-detects protocol
if display.supported() {
    display.show("photo.png", 10, 5, 60, 30);  // x, y, max_w, max_h
    // ... later ...
    display.clear(10, 5, 60, 30, 80, 24);      // Clear region
}

Supported Protocols

Protocol Terminals Detection
Kitty kitty, WezTerm TERM=xterm-kitty, KITTY_WINDOW_ID, TERM_PROGRAM=WezTerm
Sixel xterm, mlterm, foot TERM starts with xterm/mlterm/foot
W3m Any X11 terminal /usr/lib/w3m/w3mimgdisplay exists

API

pub struct Display { ... }

impl Display {
    pub fn new() -> Self;                    // Auto-detect protocol
    pub fn supported(&self) -> bool;         // Check if display works
    pub fn protocol(&self) -> Option<Protocol>; // Which protocol

    pub fn show(&mut self,
        image_path: &str,                    // Path to image file
        x: u16, y: u16,                     // Character position
        max_width: u16, max_height: u16     // Max size in chars
    ) -> bool;                               // Success

    pub fn clear(&mut self,
        x: u16, y: u16,                     // Region position
        width: u16, height: u16,            // Region size
        term_width: u16, term_height: u16   // Terminal size
    );
}

How It Works

  • Kitty: Scales image with ImageMagick convert, base64 encodes, transmits in 4KB chunks via escape sequences. Caches processed images by path+dimensions+mtime.
  • Sixel: Uses convert to generate sixel output directly.
  • W3m: Calculates pixel coordinates from cell size, communicates with w3mimgdisplay.

Runtime Requirements

  • ImageMagick (convert) - required for kitty and sixel protocols
  • w3mimgdisplay - required for w3m protocol only
  • xdotool + xwininfo - required for w3m protocol only

Part of the Fe2O3 Rust Terminal Suite

See the Fe₂O₃ suite overview and the landing page for the full list of projects.

Tool Clones Type
rush rsh Shell
crust rcurses TUI library
glow termpix Image display
plot termchart Charts
pointer RTFM File manager

License

Unlicense - public domain.

Credits

Created by Geir Isene (https://isene.org) with extensive pair-programming with Claude Code.

About

Rust terminal image display (kitty/sixel/w3m). Feature clone of termpix. Part of Fe2O3 suite.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages