new Image(srcPath [, srcOpts] [, injects])
Creates new instance of Image.
Parameters:
| Name | Type | Argument | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
srcPath |
string | path to processed image |
||||||||||||||||
srcOpts |
object |
<optional> |
image options Properties
|
|||||||||||||||
injects |
object |
<optional> |
Dependency injections. Properties
|
Methods
-
<protected> _cropPixels(pixels)
-
Crops pixels, removes empty rows and columns.
Parameters:
Name Type Description pixelsArray.<Array.<object>> pixels matrix
Returns:
- cropped pixels matrix
- Type
- Array.<Array.<object>>
-
<protected> _cropTop(pixels)
-
Crops top part of pixels matrix.
Parameters:
Name Type Description pixelsArray.<Array.<object>> pixels matrix
Returns:
- cropped pixels matrix
- Type
- Array.<Array.<object>>
-
<protected> _getDiffValue(srcPixels, dstPixels, offsetX, offsetY)
-
Calculates difference between source pixels and destination pixels.
Parameters:
Name Type Description srcPixelsArray.<Array.<object>> source pixels matrix
dstPixelsArray.<Array.<object>> destination pixels matrix
offsetXnumber source left border offset
offsetYnumber source top border offset
Returns:
- difference value
- Type
- number
-
<protected> _getPixels(img)
-
Retrieves pixels from image data.
Parameters:
Name Type Description imgobject image data
Returns:
- pixels matrix
- Type
- Array.<Array.<object>>
-
<protected> _getUsedPixels(pixels)
-
Gets used pixels.
Parameters:
Name Type Description pixelsArray.<Array.<object>> pixels matrix
Returns:
List of used pixels.
- Type
- Array.<object>
-
<protected> _includes(src, dst)
-
Defines whether one image data includes another.
Parameters:
Name Type Description srcobject source image data
dstobject destination image data, which is potentially included
Returns:
- result
- Type
- object
-
<protected> _isPixelTolerant(srcPixel, dstPixel)
-
Defines whether source pixel is tolerant to destination pixel.
Parameters:
Name Type Description srcPixelobject source pixel
dstPixelobject destination pixel
Returns:
trueif pixels are tolerant,falseotherwise
- Type
- boolean
-
<protected> _isPixelUsed(pixel)
-
Defines whether pixel should be used for difference calculation or no, according its alpha value.
Parameters:
Name Type Description pixelobject pixel
Returns:
trueif should be,falseotherwise
- Type
- boolean
-
<async, protected> _loadImg(imgPath, imgOpts)
-
Loads image.
Parameters:
Name Type Description imgPathstring path loaded image
imgOptsobject image options
Returns:
- image data
- Type
- Promise.<object>
-
<async, protected> _saveMatchImage(left, top, width, height)
-
Saves matched part of image.
Parameters:
Name Type Description leftnumber offset from left image border
topnumber offset from top image border
widthnumber width of matched part
heightnumber height of matched part
Returns:
- Type
- Promise.<void>
-
_transpose(pixels)
-
Transposes pixels matrix.
Parameters:
Name Type Description pixelsArray.<Array.<object>> pixels matrix
Returns:
transposed pixels matrix
- Type
- Array.<Array.<object>>
-
equalTo(dstPath [, dstOpts])
-
Defines if processed image equal to specified image.
Parameters:
Name Type Argument Description dstPathstring path to potentially equal image
dstOptsobject <optional>
included image options
Properties
Name Type Argument Default Description tolerancenumber <optional>
0.05 comparison tolerance
diffPathstring <optional>
<nullable>
null path to save captured difference.
saveDiffboolean <optional>
false flag to capture images intersection or no
Returns:
Ratio of difference.
- Type
- Promise.<number>
-
includes(dstPath [, dstOpts])
-
Defines if processed image includes specified image.
Parameters:
Name Type Argument Description dstPathstring path to potentially included image
dstOptsobject <optional>
included image options
Properties
Name Type Argument Default Description tolerancenumber <optional>
0.05 comparison tolerance
matchedPathstring <optional>
<nullable>
null path to same captured place
saveMatchboolean <optional>
false flag to capture images intersection or no
Returns:
- result
- Type
- Promise.<object>
-
<async> isBlack()
-
Defines whether processed image is black.
Returns:
trueif image is black,falseotherwise.
- Type
- Promise.<boolean>
-
<async> isMonochrome()
-
Defines whether processed image is monochrome.
Returns:
trueif image is monochrome,falseotherwise.
- Type
- Promise.<boolean>
-
<async> isTransparent()
-
Defines whether processed image is transparent.
Returns:
trueif image is transparent,falseotherwise.
- Type
- Promise.<boolean>
-
<async> isWhite()
-
Defines whether processed image is white.
Returns:
trueif image is white,falseotherwise.
- Type
- Promise.<boolean>