BlinkDiff Class
Blink-diff comparison class
Constructor
BlinkDiff
-
options
Parameters:
-
options
Object-
imageA
PNGImage | BufferImage object of first image
-
imageAPath
StringPath to first image
-
imageB
PNGImage | BufferImage object of second image
-
imageBPath
StringPath to second image
-
[imageOutputPath=undefined]
String optionalPath to output image file
-
[imageOutputLimit=BlinkDiff.OUTPUT_ALL]
Int optionalDetermines when an image output is created
-
[thresholdType=BlinkDiff.THRESHOLD_PIXEL]
String optionalDefines the threshold of the comparison
-
[threshold=500]
Int optionalThreshold limit according to the comparison limit.
-
[delta=20]
Number optionalDistance between the color coordinates in the 4 dimensional color-space that will not trigger a difference.
-
[outputMaskRed=255]
Int optionalValue to set for red on difference pixel. 'Undefined' will not change the value.
-
[outputMaskGreen=0]
Int optionalValue to set for green on difference pixel. 'Undefined' will not change the value.
-
[outputMaskBlue=0]
Int optionalValue to set for blue on difference pixel. 'Undefined' will not change the value.
-
[outputMaskAlpha=255]
Int optionalValue to set for the alpha channel on difference pixel. 'Undefined' will not change the value.
-
[outputMaskOpacity=0.7]
Float optionalStrength of masking the pixel. 1.0 means that the full color will be used; anything less will mix-in the original pixel.
-
[outputShiftRed=255]
Int optionalValue to set for red on shifted pixel. 'Undefined' will not change the value.
-
[outputShiftGreen=165]
Int optionalValue to set for green on shifted pixel. 'Undefined' will not change the value.
-
[outputShiftBlue=0]
Int optionalValue to set for blue on shifted pixel. 'Undefined' will not change the value.
-
[outputShiftAlpha=255]
Int optionalValue to set for the alpha channel on shifted pixel. 'Undefined' will not change the value.
-
[outputShiftOpacity=0.7]
Float optionalStrength of masking the shifted pixel. 1.0 means that the full color will be used; anything less will mix-in the original pixel.
-
[outputBackgroundRed=0]
Int optionalValue to set for red as background. 'Undefined' will not change the value.
-
[outputBackgroundGreen=0]
Int optionalValue to set for green as background. 'Undefined' will not change the value.
-
[outputBackgroundBlue=0]
Int optionalValue to set for blue as background. 'Undefined' will not change the value.
-
[outputBackgroundAlpha=undefined]
Int optionalValue to set for the alpha channel as background. 'Undefined' will not change the value.
-
[outputBackgroundOpacity=0.6]
Float optionalStrength of masking the pixel. 1.0 means that the full color will be used; anything less will mix-in the original pixel.
-
[blockOut]
Object | Object[] optionalObject or list of objects with coordinates of blocked-out areas.
-
[blockOutRed=0]
Int optionalValue to set for red on blocked-out pixel. 'Undefined' will not change the value.
-
[blockOutGreen=0]
Int optionalValue to set for green on blocked-out pixel. 'Undefined' will not change the value.
-
[blockOutBlue=0]
Int optionalValue to set for blue on blocked-out pixel. 'Undefined' will not change the value.
-
[blockOutAlpha=255]
Int optionalValue to set for the alpha channel on blocked-out pixel. 'Undefined' will not change the value.
-
[blockOutOpacity=1.0]
Float optionalStrength of masking the blocked-out pixel. 1.0 means that the full color will be used; anything less will mix-in the original pixel.
-
[copyImageAToOutput=true]
Boolean optionalCopies the first image to the output image before the comparison begins. This will make sure that the output image will highlight the differences on the first image.
-
[copyImageBToOutput=false]
Boolean optionalCopies the second image to the output image before the comparison begins. This will make sure that the output image will highlight the differences on the second image.
-
[filter=[]
String[] optionalFilters that will be applied before the comparison. Available filters are: blur, grayScale, lightness, luma, luminosity, sepia
-
[debug=false]
Boolean optionalWhen set, then the applied filters will be shown on the output image.
-
[composition=true]
Boolean optionalShould a composition be created to compare?
-
[composeLeftToRight=false]
Boolean optionalCreate composition from left to right, otherwise let it decide on its own whats best
-
[composeTopToBottom=false]
Boolean optionalCreate composition from top to bottom, otherwise let it decide on its own whats best
-
[hideShift=false]
Boolean optionalHides shift highlighting by using the background color instead
-
[hShift=2]
Int optionalHorizontal shift for possible antialiasing
-
[vShift=2]
Int optionalVertical shift for possible antialiasing
-
[cropImageA=null]
Object optionalCropping for first image (default: no cropping)
-
[x=0]
Int optionalCoordinate for left corner of cropping region -
[y=0]
Int optionalCoordinate for top corner of cropping region -
[width]
Int optionalWidth of cropping region (default: Width that is left) -
[height]
Int optionalHeight of cropping region (default: Height that is left)
-
-
[cropImageB=null]
Object optionalCropping for second image (default: no cropping)
-
[x=0]
Int optionalCoordinate for left corner of cropping region -
[y=0]
Int optionalCoordinate for top corner of cropping region -
[width]
Int optionalWidth of cropping region (default: Width that is left) -
[height]
Int optionalHeight of cropping region (default: Height that is left)
-
-
[perceptual=false]
Boolean optionalTurns perceptual comparison on
-
[gamma]
Float optionalGamma correction for all colors
-
[gammaR]
Float optionalGamma correction for red
-
[gammaG]
Float optionalGamma correction for green
-
[gammaB]
Float optionalGamma correction for blue
-
Item Index
Methods
- _calculateLowerLimit
- _calculateUpperLimit
- _clip
- _colorDelta
- _compare
- _convertResultCodeToRelativeValue
- _convertRgbToXyz
- _convertXyzToCieLab
- _copyImage
- _correctDimensions
- _correctGamma
- _createComposition
- _crop
- _getColor
- _loadImage
- _pixelCompare
- _shiftCompare
- _withinOutputLimit
- hasPassed
- isAboveThreshold
- log
- run
- runWithPromise
Properties
- OUTPUT_ALL static
- OUTPUT_DIFFERENT static
- OUTPUT_SIMILAR static
- RESULT_DIFFERENT static
- RESULT_IDENTICAL static
- RESULT_SIMILAR static
- RESULT_UNKNOWN static
- THRESHOLD_PERCENT static
- THRESHOLD_PIXEL static
- version static
Methods
_calculateLowerLimit
-
value
-
min
-
shift
Calculates the lower limit
Parameters:
-
value
Int -
min
Int -
shift
Int
Returns:
_calculateUpperLimit
-
value
-
max
-
shift
Calculates the upper limit
Parameters:
-
value
Int -
max
Int -
shift
Int
Returns:
_clip
-
imageA
-
imageB
Clips the images to the lower resolution of both
Parameters:
-
imageA
PNGImageSource image
-
imageB
PNGImageDestination image
_colorDelta
-
color1
-
color2
Calculates the distance of colors in the 4 dimensional color space
Parameters:
-
color1
ObjectValues for color 1
-
c1
IntFirst value of color 1
-
c2
IntSecond value of color 1
-
c3
IntThird value of color 1
-
c4
IntFourth value of color 1
-
-
color2
ObjectValues for color 2
-
c1
IntFirst value of color 2
-
c2
IntSecond value of color 2
-
c3
IntThird value of color 2
-
c4
IntFourth value of color 2
-
Returns:
Distance
_compare
-
imageA
-
imageB
-
imageOutput
-
deltaThreshold
-
outputMaskColor
-
outputShiftColor
-
backgroundColor
-
[hShift=0]
-
[vShift=0]
-
[perceptual=false]
-
[gamma]
Compares the two images supplied
Parameters:
-
imageA
PNGImage -
imageB
PNGImage -
imageOutput
PNGImage -
deltaThreshold
Number -
outputMaskColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
outputShiftColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
backgroundColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
[hShift=0]
Int optionalHorizontal shift
-
[vShift=0]
Int optionalVertical shift
-
[perceptual=false]
Boolean optional -
[gamma]
Object optional
Returns:
_convertResultCodeToRelativeValue
-
resultCode
Converts the result-code to a relative value
Parameters:
-
resultCode
Int
Returns:
_convertRgbToXyz
-
color
Converts the color from RGB to XYZ
Parameters:
-
color
Object
Returns:
_convertXyzToCieLab
-
color
Converts the color from XYZ to CieLab
Parameters:
-
color
Object
Returns:
_copyImage
-
imageSrc
-
imageDst
Copies one image into another image
Parameters:
-
imageSrc
PNGImage -
imageDst
PNGImage
_correctDimensions
-
width
-
height
-
rect
Correcting area dimensions if necessary
Note: Priority is on the x/y coordinates, and not on the size since the size will then be removed anyways.
Parameters:
-
width
Int -
height
Int -
rect
ObjectValues for rect
-
x
IntX value of rect
-
y
IntY value of rect
-
width
IntWidth value of rect
-
height
IntHeight value of rect
-
_correctGamma
-
color
-
[gamma]
Correct gamma and return color in [0, 1] range
Returns:
}
_createComposition
-
imageA
-
imageB
-
imageOutput
Creates a comparison image
Parameters:
-
imageA
PNGImage -
imageB
PNGImage -
imageOutput
PNGImage
Returns:
_crop
-
which
-
image
-
rect
Crops the source image to the bounds of rect
_getColor
-
image
-
idx
-
[perceptual=false]
-
[gamma]
Gets the color of an image by the index
Parameters:
Returns:
Color
_loadImage
-
path
-
image
Loads the image or uses the already available image
Parameters:
-
path
String -
image
PNGImage
Returns:
_pixelCompare
-
imageA
-
imageB
-
imageOutput
-
deltaThreshold
-
width
-
height
-
outputMaskColor
-
outputShiftColor
-
backgroundColor
-
[hShift=0]
-
[vShift=0]
-
[perceptual=false]
-
[gamma]
Does a quick comparison between the supplied images
Parameters:
-
imageA
PNGImage -
imageB
PNGImage -
imageOutput
PNGImage -
deltaThreshold
Number -
width
IntWidth of image
-
height
IntHeight of image
-
outputMaskColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
outputShiftColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
backgroundColor
Object-
[red]
Int optional -
[green]
Int optional -
[blue]
Int optional -
[alpha]
Int optional -
[opacity]
Float optional
-
-
[hShift=0]
Int optionalHorizontal shift
-
[vShift=0]
Int optionalVertical shift
-
[perceptual=false]
Boolean optional -
[gamma]
Object optional
Returns:
Number of pixel differences
_shiftCompare
-
x
-
y
-
color
-
deltaThreshold
-
imageA
-
imageB
-
width
-
height
-
hShift
-
vShift
-
[perceptual=false]
-
[gamma]
Checks if any pixel in the shift surrounding has a comparable color
Parameters:
Returns:
Is pixel within delta found in surrounding?
_withinOutputLimit
-
resultCode
-
outputLimit
Determines if result is within the output limit
Parameters:
-
resultCode
Int -
outputLimit
Int
Returns:
hasPassed
-
result
Has comparison passed?
Parameters:
-
result
IntComparison result-code
Returns:
isAboveThreshold
-
items
-
[total]
Is the difference above the set threshold?
Parameters:
-
items
Int -
[total]
Int optional
Returns:
log
-
text
Log method that can be overwritten to modify the logging behavior.
Parameters:
-
text
String
run
-
fn
Runs the comparison in node-style
Parameters:
-
fn
Function
Example:
var blinkDiff = BlinkDiff(...);
blinkDiff.run(function (err, result) {
if (err) {
throw err;
}
...
});
runWithPromise
()
Promise
Runs the comparison with a promise
Returns:
Example:
var blinkDiff = BlinkDiff(...);
blinkDiff.runWithPromise().then(function (result) {
...
});
Properties
OUTPUT_ALL
Int
static
Force output of all comparisons
OUTPUT_DIFFERENT
Int
static
Create output when images are different
OUTPUT_SIMILAR
Int
static
Create output when images are similar or different
RESULT_DIFFERENT
Int
static
The images are too different
RESULT_IDENTICAL
Int
static
The images are identical (or near identical)
RESULT_SIMILAR
Int
static
The images are very similar, but still below the threshold
RESULT_UNKNOWN
Int
static
Unknown result of the comparison