termimage

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package termimage renders images inline in terminals that support it.

Two protocols are covered:

  • iTerm2 (also honoured by WezTerm): a single OSC 1337 escape carrying the raw file bytes base64-encoded. Format-agnostic — any image the terminal can decode works.
  • kitty graphics protocol: only PNG can be transmitted directly without a decoder, so non-PNG input is rejected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(proto Protocol, mime string, data []byte) ([]byte, error)

Encode renders data as an inline-image escape sequence for proto.

Types

type Protocol

type Protocol int

Protocol identifies a detected terminal graphics protocol.

const (
	// None means the terminal supports no inline-image protocol.
	None Protocol = iota
	// ITerm is the iTerm2 OSC 1337 protocol, also honoured by WezTerm.
	ITerm
	// Kitty is the kitty graphics protocol.
	Kitty
)

func Detect

func Detect() Protocol

Detect picks a protocol from the current process environment.

func ProtocolFrom

func ProtocolFrom(termProgram, term, kittyWindowID string) Protocol

ProtocolFrom picks a protocol from terminal environment values (TERM_PROGRAM, TERM and KITTY_WINDOW_ID).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL