imageio

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package imageio loads a local image (or validates a data URI) into a data:image/...;base64,... URI for the multimodal vision path. It NEVER fetches a remote URL — only local files and pre-built data URIs are accepted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadImageB64

func LoadImageB64(pathOrDataURI string, maxBytes int) (string, error)

LoadImageB64 returns a data:image/<type>;base64,<...> URI for pathOrDataURI.

  • If the arg is already a data: URI, it is validated to be an image/* base64 URI and returned unchanged (rejected otherwise).
  • If it looks like an http(s) URL, it is rejected — remote fetches are never allowed.
  • Otherwise it is treated as a local file path: read (rejected if larger than maxBytes), type-sniffed from magic bytes (PNG/JPEG/WebP/GIF), and base64-encoded into a data URI. An unknown type is rejected.

maxBytes <= 0 means "no size limit" (the file is read whatever its size).

Types

This section is empty.

Jump to

Keyboard shortcuts

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