image

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package image provides image processing utilities for the OpenCode TUI.

This package includes functions for:

  • Validating image file sizes before display
  • Converting images to ANSI-art string representations for terminal display
  • Image resizing using Lanczos algorithm for quality downscaling

The package uses the lipgloss library for terminal styling and the disintegration/imaging library for image processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImagePreview

func ImagePreview(width int, filename string) (string, error)

ImagePreview loads an image file and converts it to an ANSI-art string. The image is resized to fit the specified width and rendered using ToString function. Returns the ANSI string or an error if loading fails.

func ToString

func ToString(width int, img image.Image) string

ToString converts an image to an ANSI-art string representation. The image is first resized to the given width using Lanczos algorithm, then converted to a string using Unicode block characters (▀) with foreground and background colors to simulate the image in terminal. Each pair of vertical pixels is rendered as one block character.

func ValidateFileSize

func ValidateFileSize(filePath string, sizeLimit int64) (bool, error)

ValidateFileSize checks if a file exceeds a given size limit. Returns true if the file is too large, along with any error encountered. This is useful for preventing memory issues when loading large images.

Types

This section is empty.

Jump to

Keyboard shortcuts

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