API Docs for: 1.0.9
Show:

BlinkDiff Class

Defined in: index.js:8

Blink-diff comparison class

Constructor

BlinkDiff

(
  • options
)

Defined in index.js:8

Parameters:

  • options Object
    • imageA PNGImage | Buffer

      Image object of first image

    • imageAPath String

      Path to first image

    • imageB PNGImage | Buffer

      Image object of second image

    • imageBPath String

      Path to second image

    • [imageOutputPath=undefined] String optional

      Path to output image file

    • [imageOutputLimit=BlinkDiff.OUTPUT_ALL] Int optional

      Determines when an image output is created

    • [thresholdType=BlinkDiff.THRESHOLD_PIXEL] String optional

      Defines the threshold of the comparison

    • [threshold=500] Int optional

      Threshold limit according to the comparison limit.

    • [delta=20] Number optional

      Distance between the color coordinates in the 4 dimensional color-space that will not trigger a difference.

    • [outputMaskRed=255] Int optional

      Value to set for red on difference pixel. 'Undefined' will not change the value.

    • [outputMaskGreen=0] Int optional

      Value to set for green on difference pixel. 'Undefined' will not change the value.

    • [outputMaskBlue=0] Int optional

      Value to set for blue on difference pixel. 'Undefined' will not change the value.

    • [outputMaskAlpha=255] Int optional

      Value to set for the alpha channel on difference pixel. 'Undefined' will not change the value.

    • [outputMaskOpacity=0.7] Float optional

      Strength 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 optional

      Value to set for red on shifted pixel. 'Undefined' will not change the value.

    • [outputShiftGreen=165] Int optional

      Value to set for green on shifted pixel. 'Undefined' will not change the value.

    • [outputShiftBlue=0] Int optional

      Value to set for blue on shifted pixel. 'Undefined' will not change the value.

    • [outputShiftAlpha=255] Int optional

      Value to set for the alpha channel on shifted pixel. 'Undefined' will not change the value.

    • [outputShiftOpacity=0.7] Float optional

      Strength 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 optional

      Value to set for red as background. 'Undefined' will not change the value.

    • [outputBackgroundGreen=0] Int optional

      Value to set for green as background. 'Undefined' will not change the value.

    • [outputBackgroundBlue=0] Int optional

      Value to set for blue as background. 'Undefined' will not change the value.

    • [outputBackgroundAlpha=undefined] Int optional

      Value to set for the alpha channel as background. 'Undefined' will not change the value.

    • [outputBackgroundOpacity=0.6] Float optional

      Strength 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[] optional

      Object or list of objects with coordinates of blocked-out areas.

    • [blockOutRed=0] Int optional

      Value to set for red on blocked-out pixel. 'Undefined' will not change the value.

    • [blockOutGreen=0] Int optional

      Value to set for green on blocked-out pixel. 'Undefined' will not change the value.

    • [blockOutBlue=0] Int optional

      Value to set for blue on blocked-out pixel. 'Undefined' will not change the value.

    • [blockOutAlpha=255] Int optional

      Value to set for the alpha channel on blocked-out pixel. 'Undefined' will not change the value.

    • [blockOutOpacity=1.0] Float optional

      Strength 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 optional

      Copies 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 optional

      Copies 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[] optional

      Filters that will be applied before the comparison. Available filters are: blur, grayScale, lightness, luma, luminosity, sepia

    • [debug=false] Boolean optional

      When set, then the applied filters will be shown on the output image.

    • [composition=true] Boolean optional

      Should a composition be created to compare?

    • [composeLeftToRight=false] Boolean optional

      Create composition from left to right, otherwise let it decide on its own whats best

    • [composeTopToBottom=false] Boolean optional

      Create composition from top to bottom, otherwise let it decide on its own whats best

    • [hideShift=false] Boolean optional

      Hides shift highlighting by using the background color instead

    • [hShift=2] Int optional

      Horizontal shift for possible antialiasing

    • [vShift=2] Int optional

      Vertical shift for possible antialiasing

    • [cropImageA=null] Object optional

      Cropping for first image (default: no cropping)

      • [x=0] Int optional
        Coordinate for left corner of cropping region
      • [y=0] Int optional
        Coordinate for top corner of cropping region
      • [width] Int optional
        Width of cropping region (default: Width that is left)
      • [height] Int optional
        Height of cropping region (default: Height that is left)
    • [cropImageB=null] Object optional

      Cropping for second image (default: no cropping)

      • [x=0] Int optional
        Coordinate for left corner of cropping region
      • [y=0] Int optional
        Coordinate for top corner of cropping region
      • [width] Int optional
        Width of cropping region (default: Width that is left)
      • [height] Int optional
        Height of cropping region (default: Height that is left)
    • [perceptual=false] Boolean optional

      Turns perceptual comparison on

    • [gamma] Float optional

      Gamma correction for all colors

    • [gammaR] Float optional

      Gamma correction for red

    • [gammaG] Float optional

      Gamma correction for green

    • [gammaB] Float optional

      Gamma correction for blue

Methods

_calculateLowerLimit

(
  • value
  • min
  • shift
)
Int private

Defined in index.js:842

Calculates the lower limit

Parameters:

  • value Int
  • min Int
  • shift Int

Returns:

Int:

_calculateUpperLimit

(
  • value
  • max
  • shift
)
Int private

Defined in index.js:856

Calculates the upper limit

Parameters:

  • value Int
  • max Int
  • shift Int

Returns:

Int:

_clip

(
  • imageA
  • imageB
)
private

Defined in index.js:620

Clips the images to the lower resolution of both

Parameters:

  • imageA PNGImage

    Source image

  • imageB PNGImage

    Destination image

_colorDelta

(
  • color1
  • color2
)
Number private

Defined in index.js:709

Calculates the distance of colors in the 4 dimensional color space

Parameters:

  • color1 Object

    Values for color 1

    • c1 Int

      First value of color 1

    • c2 Int

      Second value of color 1

    • c3 Int

      Third value of color 1

    • c4 Int

      Fourth value of color 1

  • color2 Object

    Values for color 2

    • c1 Int

      First value of color 2

    • c2 Int

      Second value of color 2

    • c3 Int

      Third value of color 2

    • c4 Int

      Fourth value of color 2

Returns:

Number:

Distance

_compare

(
  • imageA
  • imageB
  • imageOutput
  • deltaThreshold
  • outputMaskColor
  • outputShiftColor
  • backgroundColor
  • [hShift=0]
  • [vShift=0]
  • [perceptual=false]
  • [gamma]
)
Object private

Defined in index.js:990

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 optional

    Horizontal shift

  • [vShift=0] Int optional

    Vertical shift

  • [perceptual=false] Boolean optional
  • [gamma] Object optional

Returns:

_convertResultCodeToRelativeValue

(
  • resultCode
)
Int private

Defined in index.js:488

Converts the result-code to a relative value

Parameters:

  • resultCode Int

Returns:

Int:

_convertRgbToXyz

(
  • color
)
Object private

Defined in index.js:796

Converts the color from RGB to XYZ

Parameters:

Returns:

_convertXyzToCieLab

(
  • color
)
Object private

Defined in index.js:815

Converts the color from XYZ to CieLab

Parameters:

Returns:

_copyImage

(
  • imageSrc
  • imageDst
)
private

Defined in index.js:563

Copies one image into another image

Parameters:

  • imageSrc PNGImage
  • imageDst PNGImage

_correctDimensions

(
  • width
  • height
  • rect
)
private

Defined in index.js:671

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 Object

    Values for rect

    • x Int

      X value of rect

    • y Int

      Y value of rect

    • width Int

      Width value of rect

    • height Int

      Height value of rect

_correctGamma

(
  • color
  • [gamma]
)
C1: number, c2: number, c3: number, c4: number private

Defined in index.js:765

Correct gamma and return color in [0, 1] range

Parameters:

Returns:

C1: number, c2: number, c3: number, c4: number:

}

_createComposition

(
  • imageA
  • imageB
  • imageOutput
)
PNGImage private

Defined in index.js:505

Creates a comparison image

Parameters:

  • imageA PNGImage
  • imageB PNGImage
  • imageOutput PNGImage

Returns:

PNGImage:

_crop

(
  • which
  • image
  • rect
)
private

Defined in index.js:651

Crops the source image to the bounds of rect

Parameters:

  • which String

    Title of image to crop

  • image PNGImage

    Source image

  • rect Object

    Values for rect

    • x Int

      X value of rect

    • y Int

      Y value of rect

    • width Int

      Width value of rect

    • height Int

      Height value of rect

_getColor

(
  • image
  • idx
  • [perceptual=false]
  • [gamma]
)
Object private

Defined in index.js:737

Gets the color of an image by the index

Parameters:

  • image PNGImage

    Image

  • idx Int

    Index of pixel in image

  • [perceptual=false] Boolean optional
  • [gamma] Object optional

Returns:

Object:

Color

_loadImage

(
  • path
  • image
)
PNGImage | Promise private

Defined in index.js:541

Loads the image or uses the already available image

Parameters:

Returns:

PNGImage | Promise:

_pixelCompare

(
  • imageA
  • imageB
  • imageOutput
  • deltaThreshold
  • width
  • height
  • outputMaskColor
  • outputShiftColor
  • backgroundColor
  • [hShift=0]
  • [vShift=0]
  • [perceptual=false]
  • [gamma]
)
Int private

Defined in index.js:925

Does a quick comparison between the supplied images

Parameters:

  • imageA PNGImage
  • imageB PNGImage
  • imageOutput PNGImage
  • deltaThreshold Number
  • width Int

    Width of image

  • height Int

    Height 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 optional

    Horizontal shift

  • [vShift=0] Int optional

    Vertical shift

  • [perceptual=false] Boolean optional
  • [gamma] Object optional

Returns:

Int:

Number of pixel differences

_shiftCompare

(
  • x
  • y
  • color
  • deltaThreshold
  • imageA
  • imageB
  • width
  • height
  • hShift
  • vShift
  • [perceptual=false]
  • [gamma]
)
Boolean private

Defined in index.js:870

Checks if any pixel in the shift surrounding has a comparable color

Parameters:

  • x Int
  • y Int
  • color Object
  • deltaThreshold Number
  • imageA PNGImage
  • imageB PNGImage
  • width Int
  • height Int
  • hShift Int
  • vShift Int
  • [perceptual=false] Boolean optional
  • [gamma] Object optional

Returns:

Boolean:

Is pixel within delta found in surrounding?

_withinOutputLimit

(
  • resultCode
  • outputLimit
)
Boolean private

Defined in index.js:475

Determines if result is within the output limit

Parameters:

  • resultCode Int
  • outputLimit Int

Returns:

hasPassed

(
  • result
)
Boolean

Defined in index.js:608

Has comparison passed?

Parameters:

  • result Int

    Comparison result-code

Returns:

isAboveThreshold

(
  • items
  • [total]
)
Boolean

Defined in index.js:576

Is the difference above the set threshold?

Parameters:

  • items Int
  • [total] Int optional

Returns:

log

(
  • text
)

Defined in index.js:597

Log method that can be overwritten to modify the logging behavior.

Parameters:

run

(
  • fn
)

Defined in index.js:329

Runs the comparison in node-style

Parameters:

Example:

var blinkDiff = BlinkDiff(...);
blinkDiff.run(function (err, result) {
  if (err) {
    throw err;
  }

  ...
});

runWithPromise

() Promise

Defined in index.js:314

Runs the comparison with a promise

Returns:

Promise:

Example:

var blinkDiff = BlinkDiff(...);
blinkDiff.runWithPromise().then(function (result) {
  ...
});

Properties

OUTPUT_ALL

Int static

Defined in index.js:302

Force output of all comparisons

OUTPUT_DIFFERENT

Int static

Defined in index.js:284

Create output when images are different

OUTPUT_SIMILAR

Int static

Defined in index.js:293

Create output when images are similar or different

RESULT_DIFFERENT

Int static

Defined in index.js:256

The images are too different

RESULT_IDENTICAL

Int static

Defined in index.js:274

The images are identical (or near identical)

RESULT_SIMILAR

Int static

Defined in index.js:265

The images are very similar, but still below the threshold

RESULT_UNKNOWN

Int static

Defined in index.js:247

Unknown result of the comparison

THRESHOLD_PERCENT

String static

Defined in index.js:237

Threshold-type for percent of all pixels

THRESHOLD_PIXEL

String static

Defined in index.js:228

Threshold-type for pixel

version

String static

Defined in index.js:218

Version of class