image

package
v0.0.82 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyToClipboard

func CopyToClipboard(imagePath string, imageData []byte) error

CopyToClipboard copies image to clipboard (platform-aware) Attempts to copy actual image data, not just the path

func DisplayImage

func DisplayImage(imagePath string) error

DisplayImage displays the image in terminal using rasterm Returns nil if terminal doesn't support images (graceful degradation)

func ReadFromClipboard

func ReadFromClipboard() ([]byte, error)

ReadFromClipboard reads image data from the system clipboard Returns the image data and an error if clipboard doesn't contain an image

func RenderImageToWriter added in v0.0.39

func RenderImageToWriter(w io.Writer, path string) error

RenderImageToWriter renders an image to a writer using the detected capability This is for one-shot display (e.g., DisplayImage) - uses rasterm directly

func SaveImage

func SaveImage(data []byte, outputDir, prompt string) (string, error)

SaveImage saves image data to the configured output directory Returns the path where the image was saved

Types

type DebugProvider added in v0.0.39

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

DebugProvider implements ImageProvider for local development without API costs

func NewDebugProvider added in v0.0.39

func NewDebugProvider(delaySeconds float64) *DebugProvider

NewDebugProvider creates a debug provider with an optional delay (in seconds)

func (*DebugProvider) Edit added in v0.0.39

func (p *DebugProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)

func (*DebugProvider) Generate added in v0.0.39

func (p *DebugProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

func (*DebugProvider) Name added in v0.0.39

func (p *DebugProvider) Name() string

func (*DebugProvider) SupportsEdit added in v0.0.39

func (p *DebugProvider) SupportsEdit() bool

func (*DebugProvider) SupportsMultiImage added in v0.0.39

func (p *DebugProvider) SupportsMultiImage() bool

type EditRequest

type EditRequest struct {
	Prompt      string
	InputImages []InputImage // Input images for editing (supports multiple for some providers)
	Debug       bool
}

EditRequest contains parameters for image editing

type FluxProvider

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

FluxProvider implements ImageProvider using Black Forest Labs' Flux API

func NewFluxProvider

func NewFluxProvider(apiKey, model string) *FluxProvider

func (*FluxProvider) Edit

func (p *FluxProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)

func (*FluxProvider) Generate

func (p *FluxProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

func (*FluxProvider) Name

func (p *FluxProvider) Name() string

func (*FluxProvider) SupportsEdit

func (p *FluxProvider) SupportsEdit() bool

func (*FluxProvider) SupportsMultiImage added in v0.0.33

func (p *FluxProvider) SupportsMultiImage() bool

type GeminiProvider

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

GeminiProvider implements ImageProvider using Google's Gemini API

func NewGeminiProvider

func NewGeminiProvider(apiKey string) *GeminiProvider

func (*GeminiProvider) Edit

func (*GeminiProvider) Generate

func (p *GeminiProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

func (*GeminiProvider) Name

func (p *GeminiProvider) Name() string

func (*GeminiProvider) SupportsEdit

func (p *GeminiProvider) SupportsEdit() bool

func (*GeminiProvider) SupportsMultiImage added in v0.0.33

func (p *GeminiProvider) SupportsMultiImage() bool

type GenerateRequest

type GenerateRequest struct {
	Prompt string
	Debug  bool
}

GenerateRequest contains parameters for image generation

type ImageProvider

type ImageProvider interface {
	// Name returns the provider name for logging
	Name() string

	// Generate creates a new image from a text prompt
	Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

	// Edit modifies an existing image based on a prompt
	Edit(ctx context.Context, req EditRequest) (*ImageResult, error)

	// SupportsEdit returns true if the provider supports image editing
	SupportsEdit() bool

	// SupportsMultiImage returns true if the provider supports multiple input images
	SupportsMultiImage() bool
}

ImageProvider is the interface for image generation providers

func NewImageProvider

func NewImageProvider(cfg *config.Config, providerOverride string) (ImageProvider, error)

NewImageProvider creates an image provider based on config

type ImageResult

type ImageResult struct {
	Data     []byte // Image data (PNG/JPEG)
	MimeType string // "image/png", "image/jpeg", etc.
}

ImageResult contains the generated image and metadata

type InputImage added in v0.0.33

type InputImage struct {
	Data []byte // Image data
	Path string // Path for MIME type detection
}

InputImage represents a single input image for editing

type OpenAIProvider

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

OpenAIProvider implements ImageProvider using OpenAI's API

func NewOpenAIProvider

func NewOpenAIProvider(apiKey string) *OpenAIProvider

func (*OpenAIProvider) Edit

func (*OpenAIProvider) Generate

func (p *OpenAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

func (*OpenAIProvider) Name

func (p *OpenAIProvider) Name() string

func (*OpenAIProvider) SupportsEdit

func (p *OpenAIProvider) SupportsEdit() bool

func (*OpenAIProvider) SupportsMultiImage added in v0.0.33

func (p *OpenAIProvider) SupportsMultiImage() bool

type OpenRouterProvider added in v0.0.24

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

OpenRouterProvider implements ImageProvider using OpenRouter's API

func NewOpenRouterProvider added in v0.0.24

func NewOpenRouterProvider(apiKey, model string) *OpenRouterProvider

func (*OpenRouterProvider) Edit added in v0.0.24

func (*OpenRouterProvider) Generate added in v0.0.24

func (*OpenRouterProvider) Name added in v0.0.24

func (p *OpenRouterProvider) Name() string

func (*OpenRouterProvider) SupportsEdit added in v0.0.24

func (p *OpenRouterProvider) SupportsEdit() bool

func (*OpenRouterProvider) SupportsMultiImage added in v0.0.33

func (p *OpenRouterProvider) SupportsMultiImage() bool

type RenderImageResult added in v0.0.39

type RenderImageResult struct {
	// Upload contains the upload/placement commands that must go directly to terminal
	// For Kitty: delete + transmit + placement commands
	// For iTerm/Sixel: empty (everything is in Placeholder)
	Upload string
	// Placeholder contains the displayable portion
	// For Kitty: Unicode placeholder characters
	// For iTerm/Sixel: full escape sequence
	Placeholder string
	// Full is Upload + Placeholder (for convenience in non-bubbletea contexts)
	Full string
}

RenderImageResult contains the result of rendering an image

func RenderImageToString added in v0.0.39

func RenderImageToString(path string) (RenderImageResult, error)

RenderImageToString renders an image and returns a string for display For Kitty: returns full upload sequence for first display, placeholder-only for cache For others: returns full escape sequence (same for both) The caller should cache result.Cached and use result.Full for first display.

type TerminalImageCapability added in v0.0.39

type TerminalImageCapability int

TerminalImageCapability represents the terminal's image rendering capability

const (
	CapNone  TerminalImageCapability = iota // No image support
	CapKitty                                // Kitty graphics protocol
	CapITerm                                // iTerm2 inline images
	CapSixel                                // Sixel graphics
)

func DetectCapability added in v0.0.39

func DetectCapability() TerminalImageCapability

DetectCapability detects the terminal's image rendering capability Detection order: Kitty -> iTerm -> Sixel -> None

func (TerminalImageCapability) String added in v0.0.39

func (c TerminalImageCapability) String() string

String returns the capability name

type XAIProvider added in v0.0.31

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

XAIProvider implements ImageProvider using xAI's Grok image API

func NewXAIProvider added in v0.0.31

func NewXAIProvider(apiKey, model string) *XAIProvider

func (*XAIProvider) Edit added in v0.0.31

func (p *XAIProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)

func (*XAIProvider) Generate added in v0.0.31

func (p *XAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)

func (*XAIProvider) Name added in v0.0.31

func (p *XAIProvider) Name() string

func (*XAIProvider) SupportsEdit added in v0.0.31

func (p *XAIProvider) SupportsEdit() bool

func (*XAIProvider) SupportsMultiImage added in v0.0.33

func (p *XAIProvider) SupportsMultiImage() bool

Jump to

Keyboard shortcuts

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