filepreview

package
v0.0.0-...-88b8dca Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPixelsPerColumn = 10 // approximate pixels per terminal column
	DefaultPixelsPerRow    = 20 // approximate pixels per terminal row
)

Terminal cell to pixel conversion constants These approximate the pixel dimensions of terminal cells

Variables

This section is empty.

Functions

func ClearKittyImages

func ClearKittyImages() string

ClearKittyImages clears all Kitty protocol images from the terminal

func ConvertImageToANSI

func ConvertImageToANSI(img image.Image, defaultBGColor color.Color) string

func ConvertImageToANSITransparent

func ConvertImageToANSITransparent(img image.Image) string

Types

type CachedPreview

type CachedPreview struct {
	Preview    string
	Timestamp  time.Time
	Renderer   ImageRenderer
	Dimensions string // "width,height,bgColor,sideAreaWidth"
}

type ImagePreviewCache

type ImagePreviewCache struct {
	// contains filtered or unexported fields
}

func NewImagePreviewCache

func NewImagePreviewCache(maxEntries int, expiration time.Duration) *ImagePreviewCache

func (*ImagePreviewCache) Get

func (c *ImagePreviewCache) Get(path, dimensions string, renderer ImageRenderer) (string, bool)

func (*ImagePreviewCache) Set

func (c *ImagePreviewCache) Set(path, dimensions, preview string, renderer ImageRenderer)

type ImagePreviewer

type ImagePreviewer struct {
	// contains filtered or unexported fields
}

func NewImagePreviewer

func NewImagePreviewer() *ImagePreviewer

func NewImagePreviewerWithConfig

func NewImagePreviewerWithConfig(maxEntries int, expiration time.Duration) *ImagePreviewer

func (*ImagePreviewer) ANSIRenderer

func (p *ImagePreviewer) ANSIRenderer(
	img image.Image,
	defaultBGColor string,
	maxWidth,
	maxHeight int) (string, error)

Convert image to ansi

func (*ImagePreviewer) ANSIRendererTransparent

func (p *ImagePreviewer) ANSIRendererTransparent(img image.Image, maxWidth int, maxHeight int) (string, error)

func (*ImagePreviewer) ClearKittyImages

func (p *ImagePreviewer) ClearKittyImages() string

ClearKittyImages clears all Kitty protocol images from the terminal

func (*ImagePreviewer) ImagePreview

func (p *ImagePreviewer) ImagePreview(
	path string,
	maxWidth int,
	maxHeight int,
	defaultBGColor string,
	sideAreaWidth int) (string, error)

func (*ImagePreviewer) ImagePreviewFromBytes

func (p *ImagePreviewer) ImagePreviewFromBytes(
	data []byte,
	maxWidth int,
	maxHeight int,
	defaultBGColor string,
) (string, error)

func (*ImagePreviewer) ImagePreviewWithRenderer

func (p *ImagePreviewer) ImagePreviewWithRenderer(
	path string,
	maxWidth int,
	maxHeight int,
	defaultBGColor string,
	renderer ImageRenderer,
	sideAreaWidth int) (string, error)

ImagePreviewWithRenderer generates an image preview using the specified renderer

func (*ImagePreviewer) IsKittyCapable

func (p *ImagePreviewer) IsKittyCapable() bool

IsKittyCapable checks if the terminal supports Kitty graphics protocol

type ImageRenderer

type ImageRenderer int
const (
	RendererANSI ImageRenderer = iota
	RendererKitty
)

type TerminalCapabilities

type TerminalCapabilities struct {
	// contains filtered or unexported fields
}

func NewTerminalCapabilities

func NewTerminalCapabilities() *TerminalCapabilities

func (*TerminalCapabilities) GetTerminalCellSize

func (tc *TerminalCapabilities) GetTerminalCellSize() TerminalCellSize

func (*TerminalCapabilities) InitTerminalCapabilities

func (tc *TerminalCapabilities) InitTerminalCapabilities()

type TerminalCellSize

type TerminalCellSize struct {
	PixelsPerColumn int
	PixelsPerRow    int
}

Jump to

Keyboard shortcuts

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