Help us shape the future of Go! Take the 2026 Go Developer Survey

terminalimage

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package terminalimage writes native images, image fonts, or color-block previews.

Index

Constants

This section is empty.

Variables

View Source
var ErrSavedImageChanged = errors.New("saved image contents changed before preview")

ErrSavedImageChanged means the preview bytes differ from the completed save.

Functions

func FontSupported

func FontSupported() bool

FontSupported identifies a local Apple Terminal session. Font registration and tab control must never target a remote shell or a terminal multiplexer.

func ReadSaved

func ReadSaved(ctx context.Context, path string) (image.Image, error)

ReadSaved decodes an optional preview. These limits protect terminal rendering; they never limit the API response or change the original saved image.

func ReadSavedMatching

func ReadSavedMatching(ctx context.Context, path string, expected [sha256.Size]byte) (image.Image, error)

ReadSavedMatching previews only the response bytes recorded by a prior save. Both identity checks and decoding apply to the same bounded snapshot, so a replaced path or a rewritten open file cannot substitute another image.

func Write

func Write(ctx context.Context, w io.Writer, img image.Image, protocol string, columns int) error

Write displays img at the requested width in terminal cells, preserving its aspect ratio. The caller selects the protocol and supplies a terminal writer.

Types

type FontError

type FontError struct{ Err error }

FontError means preparing a sharp preview failed before any image characters were written. The caller can still display a fallback without duplicating output.

func (*FontError) Error

func (e *FontError) Error() string

func (*FontError) Unwrap

func (e *FontError) Unwrap() error

Jump to

Keyboard shortcuts

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