Documentation
¶
Overview ¶
Package imagepreview renders low-resolution, in-terminal thumbnails of images using Unicode upper half-block characters (U+2580, "▀") combined with SGR foreground/background color codes.
The technique stacks two vertical pixels into a single character cell: the foreground color paints the top pixel and the background color paints the bottom pixel. This produces pure styled text — no graphics escape sequences — so the output survives terminal multiplexers (tmux, zellij) untouched.
The Kitty graphics protocol, Sixel, and iTerm2 inline images are deliberately NOT used: those are graphics escape-sequence protocols that tmux and zellij strip or mangle by default.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render returns a half-block ANSI thumbnail of the image, scaled to fit within maxCols x maxRows terminal cells while preserving aspect ratio.
Each terminal cell encodes two vertically-stacked pixels, so the effective pixel resolution of the thumbnail is up to maxCols x (maxRows*2).
Colors are emitted at the fidelity of the detected terminal color profile: truecolor (24-bit) when available, degrading to 256-color. When the terminal supports neither (no truecolor and no 256-color), Render returns an empty string and a nil error so the caller can fall back to a text indicator. A non-nil error is only returned when the image data cannot be decoded.
bg is the color used to composite transparent pixels (typically the terminal background). A nil bg defaults to black.
Types ¶
This section is empty.