Documentation
¶
Index ¶
- Constants
- Variables
- func DataURI(img Image) string
- func DetectMIME(data []byte) string
- func EncodeBase64(img Image) string
- func IsImageFile(path string) bool
- func Placeholder(filename string, img Image) string
- type DisplayInfo
- type Image
- type ScreenshotAction
- type ScreenshotOptions
- type ScreenshotRegion
- type ScreenshotResult
- type WindowInfo
Constants ¶
const MaxSize = 20 * 1024 * 1024
MaxSize is the maximum allowed image size (20MB).
Variables ¶
var ( MIMEJPEG = "image/jpeg" MIMEPNG = "image/png" MIMEGIF = "image/gif" MIMEWEBP = "image/webp" )
Supported MIME types.
Functions ¶
func DetectMIME ¶
DetectMIME detects image MIME type from magic bytes.
func EncodeBase64 ¶
EncodeBase64 returns the base64-encoded representation of image data.
func IsImageFile ¶
IsImageFile checks if a file path looks like an image based on extension.
func Placeholder ¶
Placeholder returns a TUI-friendly placeholder string for an image.
Types ¶
type DisplayInfo ¶ added in v1.3.126
type DisplayInfo struct {
Index int `json:"index"`
IsPrimary bool `json:"is_primary"`
Width int `json:"width"`
Height int `json:"height"`
X int `json:"x"`
Y int `json:"y"`
Name string `json:"name,omitempty"`
}
DisplayInfo describes a monitor.
func ListDisplays ¶ added in v1.3.126
func ListDisplays() ([]DisplayInfo, error)
ListDisplays returns display information on Linux using xrandr or wlr-randr.
type Image ¶
type Image struct {
Data []byte
MIME string // "image/png", "image/jpeg", etc.
Width int
Height int
}
Image represents a decoded image ready for sending to providers.
func Decode ¶
Decode decodes raw image data, detecting MIME type and dimensions. Returns an error if data exceeds MaxSize or format is unsupported.
func ReadClipboard ¶
type ScreenshotAction ¶ added in v1.3.126
type ScreenshotAction string
ScreenshotAction specifies what the screenshot tool should do.
const ( ActionCapture ScreenshotAction = "capture" ActionListDisplays ScreenshotAction = "list_displays" ActionListWindows ScreenshotAction = "list_windows" )
type ScreenshotOptions ¶ added in v1.3.126
type ScreenshotOptions struct {
Display int // 1-based monitor index, 0=primary
Window string // match by title/app name
Region *ScreenshotRegion // rectangular area
Cursor bool // include mouse cursor
DelayMs int // delay before capture
Format string // "png" or "jpeg"
Quality int // JPEG quality 1-100
OutputPath string // save to file
MaxWidth int // auto-resize max width
}
ScreenshotOptions controls screenshot capture behavior.
type ScreenshotRegion ¶ added in v1.3.126
type ScreenshotRegion struct {
X, Y, Width, Height int
}
ScreenshotRegion defines a rectangular area to capture.
type ScreenshotResult ¶ added in v1.3.126
ScreenshotResult is the output of CaptureScreen.
func CaptureScreen ¶ added in v1.3.126
func CaptureScreen(opts ScreenshotOptions) (ScreenshotResult, error)
CaptureScreen captures a screenshot on Linux by auto-detecting an available screenshot tool.
type WindowInfo ¶ added in v1.3.126
type WindowInfo struct {
ID int `json:"id"`
Title string `json:"title"`
App string `json:"app"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
WindowInfo describes a capturable window.
func ListWindows ¶ added in v1.3.126
func ListWindows() ([]WindowInfo, error)
ListWindows returns capturable windows on Linux using wmctrl.