Documentation
¶
Overview ¶
Package imagediff compares rendered images and produces deterministic visual diagnostics suitable for test failures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DimensionMismatchError ¶
DimensionMismatchError reports images whose pixel dimensions differ.
func (*DimensionMismatchError) Error ¶
func (e *DimensionMismatchError) Error() string
type Metrics ¶
type Metrics struct {
// Width and Height are the comparison-canvas dimensions. ExpectedWidth,
// ExpectedHeight, ActualWidth, and ActualHeight retain the source sizes so a
// crop regression still produces a useful report instead of a nil Result.
Width int
Height int
ExpectedWidth int
ExpectedHeight int
ActualWidth int
ActualHeight int
ChangedPixels int
MaxChannelDelta int
RMSE float64
}
Metrics describes the pixel differences between two equal-sized images. RMSE is calculated across all four non-premultiplied RGBA channels.
type MismatchError ¶
MismatchError reports a comparison that exceeded at least one tolerance. Compare still returns a complete Result alongside this error.
func (*MismatchError) Error ¶
func (e *MismatchError) Error() string
type Result ¶
type Result struct {
Metrics Metrics
Tolerance Tolerance
Passed bool
ExpectedPNG []byte
ActualPNG []byte
OverlayPNG []byte
HeatmapPNG []byte
ReportHTML []byte
}
Result contains normalized PNG artifacts and a self-contained HTML report. The report embeds all four PNGs as data URLs and has no external resources.
func Compare ¶
Compare decodes two encoded images, compares them, and creates diagnostics. PNG, JPEG, and GIF inputs are registered by this package.
func CompareImages ¶
CompareImages compares two decoded images and creates diagnostics. Image bounds may have different origins, but their dimensions must match exactly.
func (*Result) WriteReport ¶
WriteReport writes the self-contained HTML report, creating parent directories as needed.