imagepreview

package
v2026.1105.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package imagepreview renders static terminal previews without external codecs or rendering libraries. The original media remains the source of truth.

Index

Constants

View Source
const MaxBytes = 32 << 20
View Source
const MaxPixels = 32 << 20

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode bounds allocations before decoding. image/gif.Decode reads only the first image; its logical canvas and image offset are retained by canvasImage.

func Open

func Open(path string) (image.Image, error)

func Render

func Render(ctx context.Context, img image.Image, opts Options, emit func(string) error) error

Render emits each completed terminal row immediately. Working samples live in a circular window with two rows of history/look-ahead, never a full raster. Decode is separate: progressive rendering does not imply streaming decoding.

func Write

func Write(ctx context.Context, w io.Writer, img image.Image, o Options) error

Write flushes complete rows, allowing a natural top-to-bottom reveal without sleeps, cursor movement, or replacing text already printed in scrollback.

Types

type Colors

type Colors string
const (
	None      Colors = "none"
	ANSI256   Colors = "256"
	TrueColor Colors = "truecolor"
)

func DetectColors

func DetectColors(terminal bool) Colors

DetectColors is a best-effort capability hint, never a terminal query. The caller controls TTY detection and may explicitly select a color mode instead.

type Options

type Options struct {
	Width, Height int // maximum terminal columns/rows
	Colors        Colors
	CellAspect    float64 // cell width / height; normally about 0.5
	Background    color.RGBA
}

Jump to

Keyboard shortcuts

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