imgrender

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScaleToWidth added in v1.2.4

func ScaleToWidth(imgData []byte, cols int) (image.Image, error)

ScaleToWidth decodes imgData and scales it to the terminal width (cols columns, or the whole terminal when cols <= 0) for webtoon reading. It never enlarges past the native width: a 900px strip stays 900px wide on a wide terminal instead of turning blurry and huge.

func Window added in v1.2.4

func Window(img image.Image, top, rows int) (win image.Image, clampedTop, totalRows int)

Window cuts the part of a scaled page that covers terminal rows [top, top+rows). top is clamped so the window never runs past the bottom. It returns the window, the clamped top, and the page height in rows.

Types

type RenderedImage

type RenderedImage struct {
	EscapeSequence string
	WidthPx        int
	HeightPx       int
}

type Renderer

type Renderer interface {
	RenderInBox(imgData []byte, cols, rows int) (RenderedImage, error)
	RenderImage(img image.Image) (RenderedImage, error)
}

func New

func New() Renderer

New picks the renderer: FUTON_RENDERER=kitty|sixel overrides detection; Kitty for terminals known to implement its graphics protocol (kitty, Ghostty, WezTerm), since it is faster; Sixel otherwise.

type TerminalSize

type TerminalSize struct {
	Cols int
	Rows int
	PxW  int
	PxH  int
}

func GetTerminalSize

func GetTerminalSize() (TerminalSize, error)

Jump to

Keyboard shortcuts

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