Documentation
¶
Index ¶
- Variables
- func CreateSolidImage(w, h int, c color.Color) image.Image
- func EncodeImageToBase64(img image.Image) (string, error)
- func FormatJSON(w io.Writer, res *DiffResult) error
- func GenerateHTMLReport(w io.Writer, baseline, candidate, diff image.Image, res *DiffResult) error
- func GenerateMarkdownSummary(w io.Writer, res *DiffResult) error
- type DiffResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
RenderSolidRect helper to create mock test images.
func EncodeImageToBase64 ¶
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 ¶
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.