API Reference

termimage.Display

func Display(w io.Writer, path string, opts Options) error

Decodes the image at path and writes terminal graphics to w. Returns the first error encountered (file open, decode, or render failure).

termimage.Options

type Options struct {
    MaxWidth, MaxHeight int
    Protocol            Protocol
    Sandboxed           bool
}
FieldDefaultDescription
MaxWidthterminal pixel widthMax output width in pixels
MaxHeightterminal pixel height × 2Max output height in pixels
ProtocolAutoAuto, Kitty, Sixel, HalfBlock
SandboxedfalseRun decode in isolated subprocess

termimage.MaybeRunWorker

func MaybeRunWorker()

Must be called at the top of main() when using Sandboxed: true. Checks for the TERMIMAGE_WORKER=1 env var; if set, applies OS restrictions, decodes the image, writes raw RGBA to stdout, and calls os.Exit(0).

Sub-packages

PackagePurpose
decodeCGo stb_image binding. decode.File(path) and decode.Bytes(data)
detectProtocol detection. detect.Best()
renderrender.Kitty, render.Sixel, render.HalfBlock
sandboxSubprocess worker. sandbox.Decode(path)
internal/resizeresize.Fit(img, maxW, maxH) — BiLinear scale