imgload

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package imgload provides shared image path validation, safe file opening, and pixel decoding used by all GPU backends.

Index

Constants

View Source
const (
	// DefaultMaxImageBytes is the default maximum encoded image
	// size accepted by DecodeNRGBA.
	DefaultMaxImageBytes = int64(16 * 1024 * 1024)
	// DefaultMaxImagePixels is the default maximum decoded pixel
	// count accepted by DecodeNRGBA.
	DefaultMaxImagePixels = int64(40_000_000)
)

Variables

This section is empty.

Functions

func DecodeNRGBA

func DecodeNRGBA(
	path string, f *os.File,
	maxBytes, maxPixels int64,
) (*image.NRGBA, error)

DecodeNRGBA validates image limits, decodes the file, and returns the pixels as *image.NRGBA. The file is seeked to 0 before decoding.

func OpenSafe

func OpenSafe(
	path string, allowedRoots []string,
) (*os.File, error)

OpenSafe opens path with a pre/post stat TOCTOU guard. If allowedRoots is non-empty, the path is re-validated before opening.

func ResolveValidatedPath

func ResolveValidatedPath(
	src string, allowedRoots []string,
) (string, error)

ResolveValidatedPath cleans, absolutizes, and resolves symlinks for src, then validates against allowedRoots (if non-empty).

Types

This section is empty.

Jump to

Keyboard shortcuts

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