visualtest

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiffHighlightColor = color.RGBA{R: 255, G: 0, B: 128, A: 255}

DiffHighlightColor is the magenta color used to highlight pixel differences.

Functions

func CreateSolidImage

func CreateSolidImage(w, h int, c color.Color) image.Image

RenderSolidRect helper to create mock test images.

func EncodeImageToBase64

func EncodeImageToBase64(img image.Image) (string, error)

EncodeImageToBase64 converts an image.Image into a data URI base64 string.

func FormatJSON

func FormatJSON(w io.Writer, res *DiffResult) error

FormatJSON outputs DiffResult as indented JSON.

func GenerateHTMLReport

func GenerateHTMLReport(w io.Writer, baseline, candidate, diff image.Image, res *DiffResult) error

GenerateHTMLReport produces an interactive, standalone HTML diff report.

func GenerateMarkdownSummary

func GenerateMarkdownSummary(w io.Writer, res *DiffResult) error

GenerateMarkdownSummary formats the result for CI and PR comments.

Types

type DiffResult

type DiffResult struct {
	TotalPixels       int64           `json:"total_pixels"`
	MismatchedPixels  int64           `json:"mismatched_pixels"`
	DiffPercent       float64         `json:"diff_percent"`
	Passed            bool            `json:"passed"`
	MaxDiffPercent    float64         `json:"max_diff_percent"`
	DiffBounds        image.Rectangle `json:"diff_bounds"`
	DiffImagePNGBytes []byte          `json:"-"`
}

DiffResult holds the pixel-by-pixel comparison result between two images.

func Compare

func Compare(baseline, candidate image.Image, colorTolerance float64, maxDiffPercent float64) (*DiffResult, image.Image, error)

Compare compares two images pixel-by-pixel, calculates the mismatch percentage, and produces a diff image highlighting altered regions. colorTolerance defines the per-channel threshold (0.0 to 1.0) before a pixel is considered different.

Jump to

Keyboard shortcuts

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