GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - floatpane/termimage: CGo library for displaying images in your terminal securely

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
decode
decode
 
 
detect
detect
 
 
docs
docs
 
 
internal
internal
 
 
render
render
 
 
sandbox
sandbox
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.golangci.yml
.golangci.yml
 
 
.goreleaser.yml
.goreleaser.yml
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
renovate.json
renovate.json
 
 
termimage.go
termimage.go
 
 
termimage_test.go
termimage_test.go
 
 
termsize_linux.go
termsize_linux.go
 
 
termsize_stub.go
termsize_stub.go
 
 

Repository files navigation

termimage

Render images in the terminal — Kitty, Sixel, or Unicode half-blocks — with a sandboxed decoder.

Go Version Go Reference GitHub release (latest by date) CI License: MIT

termimage is a small Go library that displays images in a terminal. It auto-detects the best supported protocol (Kitty graphics, DEC Sixel, or Unicode half-blocks as fallback) and decodes images in a sandboxed subprocess (Landlock + seccomp on Linux) so untrusted bytes never touch the parent process.

Features

  • Auto-detected protocols — Kitty, Sixel, half-block fallback. Works on any modern terminal.
  • Multiple sources — local files, data: URIs (base64), and http(s):// URLs.
  • Sandboxed decoder — image bytes parsed in an isolated subprocess with Landlock + seccomp on Linux.
  • No CGO required for the consumer — pure-Go API surface; the C decoder is contained in the worker subprocess.
  • Terminal pixel detection — sizes output to the actual cell pixel dimensions when available.

Install

go get github.com/floatpane/termimage

Requires Go 1.26+.

Usage

package main

import (
    "os"

    "github.com/floatpane/termimage"
)

func main() {
    // Required: must be the first call in main() so sandbox workers can
    // re-exec into the decoder without running the rest of your program.
    termimage.MaybeRunWorker()

    err := termimage.Display(os.Stdout, "cat.png", termimage.Options{
        Protocol:  termimage.Auto,
        Sandboxed: true,
    })
    if err != nil {
        panic(err)
    }
}

Sources

The src argument accepts any of:

termimage.Display(os.Stdout, "/path/to/cat.png", opts)
termimage.Display(os.Stdout, "https://example.com/cat.png", opts)
termimage.Display(os.Stdout, "data:image/png;base64,iVBORw0KGgo...", opts)

Remote URLs and data URIs are fetched/decoded in the parent process, then handed to the sandboxed worker over stdin — the worker still runs with Landlock denying all filesystem access. Remote payloads are capped at 64 MiB.

Use DisplayContext to pass a context.Context for cancellation of HTTP fetches and decoding.

Options

Field Description
MaxWidth, MaxHeight Pixel bounds. 0 = detect from terminal.
Protocol Auto, Kitty, Sixel, or HalfBlock.
Sandboxed Decode in a Landlock + seccomp subprocess.

Protocol detection

detect.Best() inspects $TERM, $TERM_PROGRAM, and $KITTY_WINDOW_ID. No ANSI queries are sent, so it works without a TTY.

Terminal Protocol
kitty, Ghostty, WezTerm Kitty graphics
foot, mlterm, Contour, xterm-sixel Sixel
everything else half-block

Sandbox

On Linux, the worker subprocess applies:

  • Landlock — restricts filesystem access to the single image path.
  • seccomp-bpf — blocks syscalls outside a read/decode allowlist.

On other platforms, the worker runs without OS-level restrictions but is still process-isolated.

Documentation

Full API reference: pkg.go.dev/github.com/floatpane/termimage

Contributing

PRs welcome. See CONTRIBUTING.md.

Security

Report vulnerabilities privately via SECURITY.md.

License

MIT. See LICENSE.

About

CGo library for displaying images in your terminal securely

termimage.floatpane.com

Topics

clicommand-linegogolanggolang-libraryhalfblockimage-decodingimage-processingimage-viewerkitty-graphicsquantizationsandboxsecuritysixelsixel-graphicsstb-imageterminalterminal-graphicsterminal-imagetui

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

7 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.