imagecheck

package
v0.2.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package imagecheck provides deterministic, host-side encoded image inspection without external dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CropError

type CropError struct {
	Crop           image.Rectangle
	ExpectedBounds image.Rectangle
	ActualBounds   image.Rectangle
	Reason         string
}

CropError reports an empty crop or one not fully contained in both images.

func (*CropError) Error

func (err *CropError) Error() string

type DecodeError

type DecodeError struct {
	Input Input
	Err   error
}

DecodeError reports that one encoded input could not be decoded.

func (*DecodeError) Error

func (err *DecodeError) Error() string

func (*DecodeError) Unwrap

func (err *DecodeError) Unwrap() error

type DimensionMismatchError

type DimensionMismatchError struct {
	Expected image.Point
	Actual   image.Point
}

DimensionMismatchError reports unequal effective dimensions after applying the optional crop.

func (*DimensionMismatchError) Error

func (err *DimensionMismatchError) Error() string

type Input

type Input string

Input identifies one encoded image argument.

const (
	InputExpected Input = "expected"
	InputActual   Input = "actual"
)

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is an immutable pixel-inspection value. Its state is exposed only through value-returning accessors.

func Check

func Check(expected, actual []byte, crop *image.Rectangle) (Result, error)

Check decodes and checks expected and actual encoded images.

func (Result) DifferenceRatio

func (result Result) DifferenceRatio() float64

DifferenceRatio returns DifferentPixels divided by TotalPixels.

func (Result) DifferentPixels

func (result Result) DifferentPixels() uint64

DifferentPixels returns the exact number of unequal normalized RGBA pixels.

func (Result) TotalPixels

func (result Result) TotalPixels() uint64

TotalPixels returns the exact number of evaluated pixels.

func (Result) WithinThreshold

func (result Result) WithinThreshold(threshold float64) (bool, error)

WithinThreshold reports whether the difference ratio is at or below the inclusive threshold. Thresholds must be finite values in [0,1].

type ThresholdError

type ThresholdError struct {
	Threshold float64
}

ThresholdError reports a non-finite or out-of-range inspection threshold.

func (*ThresholdError) Error

func (err *ThresholdError) Error() string

Jump to

Keyboard shortcuts

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