Documentation ¶
Overview ¶
Package cmpimg compares the raw representation of images taking into account idiosyncracies related to their underlying format (SVG, PDF, PNG, ...).
Index ¶
- Variables
- func CheckPlot(ExampleFunc func(), t *testing.T, filenames ...string)
- func CheckPlotApprox(ExampleFunc func(), t *testing.T, delta float64, filenames ...string)
- func Diff(dst draw.Image, a, b image.Image) image.Rectangle
- func Equal(typ string, raw1, raw2 []byte) (bool, error)
- func EqualApprox(typ string, raw1, raw2 []byte, delta float64) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var GenerateTestData = flag.Bool("regen", false, "Uses the current state to regenerate the test data.")
Functions ¶
func CheckPlot ¶
CheckPlot checks a generated plot against a previously created reference. If GenerateTestData = true, it regenerates the reference. For image.Image formats, a base64 encoded png representation is output to the testing log when a difference is identified.
func CheckPlotApprox ¶ added in v0.9.0
CheckPlotApprox checks a generated plot against a previously created reference. The normalized delta parameter describes how tight the matching should be performed, where delta=0 expresses a perfect match, and delta=1 a very loose match. If GenerateTestData = true, it regenerates the reference. For image.Image formats, a base64 encoded png representation is output to the testing log when a difference is identified.
func Diff ¶
Diff calculates an intensity-scaled difference between images a and b and places the result in dst, returning the intersection of a, b and dst. It is the responsibility of the caller to construct dst so that it will overlap with a and b. For the purposes of Diff, alpha is not considered.
Diff is not intended to be used for quantitative analysis of the difference between the input images, but rather to highlight differences between them for testing purposes, so the calculation is rather naive.
func Equal ¶
Equal takes the raw representation of two images, raw1 and raw2, together with the underlying image type ("eps", "jpeg", "jpg", "pdf", "png", "svg", "tiff"), and returns whether the two images are equal or not.
Equal may return an error if the decoding of the raw image somehow failed.
func EqualApprox ¶ added in v0.9.0
EqualApprox takes the raw representation of two images, raw1 and raw2, together with the underlying image type ("eps", "jpeg", "jpg", "pdf", "png", "svg", "tiff"), a normalized delta parameter to describe how close the matching should be performed (delta=0: perfect match, delta=1, loose match) and returns whether the two images are equal or not.
EqualApprox may return an error if the decoding of the raw image somehow failed. EqualApprox only uses the normalized delta parameter for "jpeg", "jpg", "png", and "tiff" images. It ignores that parameter for other document types.
Types ¶
This section is empty.