TUItui/images
Terminal Images
Terminal image support is implemented in indusagi/src/tui/terminal-image.ts.
It detects capabilities and renders images using Kitty or iTerm2 protocols.
Capability Detection
detectCapabilities() inspects:
TERM_PROGRAMTERMCOLORTERM- Environment variables for Kitty, WezTerm, iTerm2, Ghostty
getCapabilities() caches the result until resetCapabilitiesCache() is called.
Image Rendering
Helpers include:
encodeKitty(base64, options)andencodeITerm2(base64, options)renderImage(base64, dimensions, options)deleteKittyImage(imageId)anddeleteAllKittyImages()
Dimensions
getImageDimensionsauto-detects size for PNG, JPEG, GIF, and WebP.calculateImageRowsconverts pixel height to terminal rows.getCellDimensionsandsetCellDimensionsmanage cell size.
Image Component
Image in indusagi/src/tui/components/image.ts renders a base64 image:
- Uses Kitty or iTerm2 if available.
- Falls back to a text placeholder from
imageFallback. - Accepts
maxWidthCells,maxHeightCells, and optionalimageId.
