filepreview

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPixelsPerColumn = 10 // approximate pixels per terminal column
	DefaultPixelsPerRow    = 20 // approximate pixels per terminal row
	WindowsPixelsPerColumn = 8  // Windows Terminal/CMD typical width
	WindowsPixelsPerRow    = 16 // Windows Terminal/CMD typical height
)

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

Variables

This section is empty.

Functions

func ConvertImageToANSI

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

ConvertImageToANSI converts an image to ANSI escape codes with proper aspect ratio

Types

type ImagePreviewer added in v1.3.2

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

ImagePreviewer encapsulates image preview functionality with caching

func NewImagePreviewer added in v1.3.2

func NewImagePreviewer() *ImagePreviewer

NewImagePreviewer creates a new ImagePreviewer with default cache settings

func NewImagePreviewerWithConfig added in v1.3.2

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

NewImagePreviewerWithConfig creates a new ImagePreviewer with custom cache configuration

func (*ImagePreviewer) ANSIRenderer added in v1.3.2

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

Convert image to ansi

func (*ImagePreviewer) GetKittyClearRaw added in v1.6.0

func (p *ImagePreviewer) GetKittyClearRaw() string

GetKittyClearRaw returns the raw APC command to clear all Kitty images. This must be sent via tea.Raw(), not embedded in view content.

func (*ImagePreviewer) ImagePreview added in v1.3.2

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

ImagePreview generates a preview of an image file. Returns (render, rawTransmit, error) where rawTransmit is non-empty only for Kitty protocol and should be sent via tea.Raw() to transmit image data directly to the terminal, bypassing the cell-based renderer.

func (*ImagePreviewer) ImagePreviewWithRenderer added in v1.3.2

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

ImagePreviewWithRenderer generates an image preview using the specified renderer. Returns (render, rawTransmit, error).

func (*ImagePreviewer) InitTerminalCapabilities added in v1.3.2

func (p *ImagePreviewer) InitTerminalCapabilities()

InitTerminalCapabilities initializes terminal capabilities for the ImagePreviewer

func (*ImagePreviewer) IsKittyCapable added in v1.3.2

func (p *ImagePreviewer) IsKittyCapable() bool

IsKittyCapable checks if the terminal supports Kitty graphics protocol

type ImageRenderer added in v1.3.2

type ImageRenderer int
const (
	RendererANSI ImageRenderer = iota
	RendererKitty
)

func (ImageRenderer) String added in v1.5.0

func (f ImageRenderer) String() string

type KittyImageResult added in v1.6.0

type KittyImageResult struct {
	// Placeholders is the Unicode placeholder string for embedding in the view.
	// It contains kitty.Placeholder characters with diacritics.
	Placeholders string
	// RawTransmit is the Kitty graphics APC data to send via tea.Raw().
	// It transmits the image data to the terminal out-of-band.
	RawTransmit string
}

KittyImageResult holds both the placeholder string for the cell buffer and the raw transmission data to send directly to the terminal.

type TerminalCapabilities added in v1.3.2

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

TerminalCapabilities encapsulates terminal capability detection

func NewTerminalCapabilities added in v1.3.2

func NewTerminalCapabilities() *TerminalCapabilities

NewTerminalCapabilities creates a new TerminalCapabilities instance

func (*TerminalCapabilities) GetTerminalCellSize added in v1.3.2

func (tc *TerminalCapabilities) GetTerminalCellSize() TerminalCellSize

GetTerminalCellSize returns the current terminal cell size If detection hasn't been initialized, it performs detection first

func (*TerminalCapabilities) InitTerminalCapabilities added in v1.3.2

func (tc *TerminalCapabilities) InitTerminalCapabilities()

InitTerminalCapabilities initializes all terminal capabilities detection including cell size and Kitty Graphics Protocol support This should be called early in the application startup

type TerminalCellSize added in v1.3.2

type TerminalCellSize struct {
	PixelsPerColumn int
	PixelsPerRow    int
}

TerminalCellSize represents the pixel dimensions of terminal cells

type ThumbnailGenerator added in v1.5.0

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

func NewThumbnailGenerator added in v1.5.0

func NewThumbnailGenerator() (*ThumbnailGenerator, error)

func (*ThumbnailGenerator) CleanUp added in v1.5.0

func (g *ThumbnailGenerator) CleanUp() error

func (*ThumbnailGenerator) GetThumbnailOrGenerate added in v1.5.0

func (g *ThumbnailGenerator) GetThumbnailOrGenerate(path string) (string, error)

func (*ThumbnailGenerator) SupportsExt added in v1.5.0

func (g *ThumbnailGenerator) SupportsExt(ext string) bool

type VideoGenerator added in v1.5.0

type VideoGenerator struct{}

Jump to

Keyboard shortcuts

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