rasterasset

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rasterasset validates manager-side image input without file/network access, HTML parsing, panel dependencies or early monochrome composition.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfiguration = errors.New("rasterasset: invalid limits")
	ErrSource        = errors.New("rasterasset: expected canonical raster data URL")
	ErrLimit         = errors.New("rasterasset: image exceeds limit")
	ErrImage         = errors.New("rasterasset: invalid raster image")
)

Functions

func DecodeDataURL

func DecodeDataURL(src string, limits Limits) (image.Image, error)

DecodeDataURL accepts only data:image/png;base64, with padded RFC4648 standard base64 and no whitespace. It returns caller-owned pixels with alpha intact; the renderer must composite against the actual scene before thresholding. No URL resolver, global image decoder registry, or source metadata is exposed.

func DecodeJPEGDataURL

func DecodeJPEGDataURL(src string, limits Limits) (image.Image, error)

DecodeJPEGDataURL accepts canonical JPEG data URLs with the same allocation limits as PNG. JPEG is opaque and lossy; it is not compared pixel-for-pixel with its pre-encoding source. DecodeConfig precedes pixel allocation. https://pkg.go.dev/image#hdr-Security_Considerations

Types

type Limits

type Limits struct {
	MaxURLBytes, MaxPNGBytes, MaxDimension, MaxPixels int
}

Limits are positive administrator-supplied per-image bounds, not HTML values. MaxURLBytes includes the prefix/base64; MaxPNGBytes bounds the decoded source file, not its pixels (the legacy field name also applies to JPEG). Callers must also enforce a document-wide asset budget.

Jump to

Keyboard shortcuts

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