Documentation
¶
Overview ¶
Package termimage renders images in a terminal using Kitty graphics, Sixel, or Unicode half-block characters as fallback. Image decoding runs inside a sandboxed subprocess (Landlock + seccomp on Linux) so untrusted bytes never touch the parent process.
The consuming binary must call MaybeRunWorker() at the very top of main():
func main() {
termimage.MaybeRunWorker()
// ... rest of your app
}
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Display ¶
Display decodes the image at src and writes terminal graphics to w. src may be a local file path, a data: URI, or an http(s):// URL.
func DisplayContext ¶ added in v0.1.0
DisplayContext is Display with caller-supplied context for cancellation of remote fetches and sandboxed decoding.
func MaybeRunWorker ¶
func MaybeRunWorker()
MaybeRunWorker must be called at the top of main(). If this process was spawned as a sandbox worker it applies OS restrictions, decodes the image, writes pixels to stdout, and exits. Otherwise it returns immediately.
Types ¶
type Options ¶
type Options struct {
// MaxWidth / MaxHeight in pixels. 0 = detect from terminal.
MaxWidth, MaxHeight int
// Protocol selects the rendering protocol. Auto detects from $TERM etc.
Protocol Protocol
// Sandboxed runs the decoder in a subprocess with Landlock + seccomp.
// Requires the consuming binary to call MaybeRunWorker() in main().
Sandboxed bool
}
Options configures image display.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package decode wraps stb_image via CGo for fast multi-format image decoding.
|
Package decode wraps stb_image via CGo for fast multi-format image decoding. |
|
Package detect identifies terminal graphics capabilities.
|
Package detect identifies terminal graphics capabilities. |
|
internal
|
|
|
resize
Package resize provides fast bilinear image scaling.
|
Package resize provides fast bilinear image scaling. |
|
source
Package source resolves image sources: file paths, data URIs, and remote URLs.
|
Package source resolves image sources: file paths, data URIs, and remote URLs. |
|
Package sandbox runs image decoding in an isolated subprocess.
|
Package sandbox runs image decoding in an isolated subprocess. |