Documentation
¶
Index ¶
Constants ¶
const DEFAULT_CONFIG_FILE = `screenshot-compare.json`
const WB = float64(0.114)
WB as defined by standard BT.601 by CCIR
const WG = float64(0.587)
WG as defined by standard BT.601 by CCIR
const WR = float64(0.299)
WR as defined by standard BT.601 by CCIR
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// ColorSpace to use for comparison.
// Currently supported: {Y'UV, RGB}
ColorSpace string
// Timeout defines a duration threshold. Timeout does not consider PreWait time.
// If comparison exceeds this duration threshold, it will terminate prematurely.
Timeout time.Duration
// PreWait defines how long to wait before comparison starts
PreWait time.Duration
// AdmissibleDiffPixel is a fixed number N of pixels that are
// allowed to be different. The comparison score will ignore the
// the first N pixels yielding _any_ difference
AdmissibleDiffPixel uint
// NoDimensionError returns the maximum difference value as Score if
// dimensions do not match instead of returning an error
NoDimensionError bool
// BaseImg is the image to compare in memory
BaseImg TaggedImage
// RefImg is the image to compare with ("expected image").
// RImg is the parsed image to compare with in memory
RefImg TaggedImage
}
Config defines the runtime configuration. Two runs of the executable with the same Config must yield the same result.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a new configuration struct with default values
func (*Config) FromArgs ¶
FromArgs parses the given arguments and stores its data in its Config struct. If mode=1, all values must be set or an error is returned. Depending on the type, it might not be possible to distinguish between 'not set' and 'zero value'. If mode=2, values will be stored iff all required values are set. If mode=3, any non-zero value will be stored. The return values are warnings (value not set) and errors (value cannot be used/parsed). If the second return value is non-nil, Config will not be modified.
func (*Config) FromEnv ¶
FromEnv parses environment variables and stores its data in its Config struct If mode=1, all values must be set or an error is returned. Depending on the type, it might not be possible to distinguish between 'not set' and 'zero value'. If mode=2, values will be stored iff all required values are set. If mode=3, any non-zero value will be stored. The return values are warnings (value not set) and errors (value cannot be used/parsed). If the second return value is non-nil, Config will not be modified.
func (*Config) FromJSON ¶
FromJSON retrieves the configuration parameters from a JSON file and stores its data in its Config struct. If `filepath` is empty, the default filepath will be used. If `silentMissingError` is true, FromJSON does not modify Config and returns nil if the JSON file does not exist. If mode=1, all values must be set or an error is returned. Depending on the type, it might not be possible to distinguish between 'not set' and 'zero value'. If mode=2, values will be stored iff all required values are set. If mode=3, any non-zero value will be stored. The return values are warnings (value not set) and errors (value cannot be used/parsed). If the second return value is non-nil, Config will not be modified.
type Result ¶
type Result struct {
// Config provides a representation of the values used to run this program.
// Useful for debugging
Config string
// Runtime gives the duration of the comparison algorithm plus waiting times
Runtime time.Duration
// Gives the number of pixels with _any_ difference between the two images.
// If PixelsDifferent is smaller or equal to AdmissibleDiffPixel, the Score must be necessarily zero.
PixelsDifferent uint
// True, if the program did not finish within the timeframe given by Timeout
Timeout bool
// Score gives the percentage of pixels with difference (minus AdmissibleDiffPixel) between two images.
// Is a value between 0 (inclusively) and 1 (inclusively)
Score float64
// contains filtered or unexported fields
}
Result is the result of an image comparison
type TaggedImage ¶
type TaggedImage struct {
// Image is an in-memory Go image.Image instance
Image image.Image
// Width gives the width of Image
Width int
// Height gives the height of Image
Height int
// MinX defines the smallest X coordinate to start comparison with
MinX int
// MinY defines the smallest Y coordinate to start comparison with
MinY int
// Format is the file format as returned by Go's image.Decode
Format string
// Source is a simple description for the source of this image (for example, its filepath)
Source string
}
TaggedImage represents an image with explicit width, height, format and source values
func (*TaggedImage) FromFilepath ¶
func (i *TaggedImage) FromFilepath(fp string) error
FromFilepath reads an image from the given filepath and fills TaggedImage with its data
func (*TaggedImage) String ¶
func (i *TaggedImage) String() string
String returns the human-readable representation of TaggedImage