imagedecode

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package imagedecode provides additive, bounded image barcode decoding.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLimitExceeded reports a caller-provided decode budget violation.
	ErrLimitExceeded = errors.New("imagedecode: limit exceeded")
	// ErrUnsupportedFormat reports a format absent from the image decoder.
	ErrUnsupportedFormat = errors.New("imagedecode: unsupported format")
	// ErrInvalidImage reports an image that cannot be converted for decoding.
	ErrInvalidImage = errors.New("imagedecode: invalid image")
	// ErrNotFound reports that no requested barcode was detected.
	ErrNotFound = errors.New("imagedecode: barcode not found")
)

Functions

func Decode

func Decode(ctx context.Context, input image.Image, options Options) (barcode.DecodeResult, error)

Decode returns the first requested format found within the configured bounds. Decoded content is data only and is never executed or followed.

func DecodeEncoded

func DecodeEncoded(ctx context.Context, input io.Reader, options Options) (barcode.DecodeResult, error)

DecodeEncoded bounds and decodes a PNG, JPEG, or GIF stream before scanning it for a barcode. The compressed byte and decoded image limits are enforced before the full image allocation.

Types

type Limits

type Limits struct {
	MaxWidth        int
	MaxHeight       int
	MaxPixels       int
	MaxCandidates   int
	MaxPayloadBytes int
	MaxRotations    int
	MaxMemoryBytes  int
	MaxEncodedBytes int
	MaxCorrections  int
	MaxDuration     time.Duration
}

Limits are enforced before image conversion and between decoder attempts. MaxRotations includes the original orientation and is limited to four.

type Options

type Options struct {
	Formats              []barcode.Format
	AllowInverted        bool
	TryHarder            bool
	AssumeCode39Checksum bool
	Limits               Limits
}

Options controls requested formats, scan behavior, and resource limits.

Jump to

Keyboard shortcuts

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