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 pixels
Array.<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 pixels
Array.<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 srcPixels
Array.<Array.<object>> source pixels matrix
dstPixels
Array.<Array.<object>> destination pixels matrix
offsetX
number source left border offset
offsetY
number source top border offset
Returns:
- difference value
- Type
- number
-
<protected> _getPixels(img)
-
Retrieves pixels from image data.
Parameters:
Name Type Description img
object image data
Returns:
- pixels matrix
- Type
- Array.<Array.<object>>
-
<protected> _getUsedPixels(pixels)
-
Gets used pixels.
Parameters:
Name Type Description pixels
Array.<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 src
object source image data
dst
object 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 srcPixel
object source pixel
dstPixel
object destination pixel
Returns:
true
if pixels are tolerant,false
otherwise
- Type
- boolean
-
<protected> _isPixelUsed(pixel)
-
Defines whether pixel should be used for difference calculation or no, according its alpha value.
Parameters:
Name Type Description pixel
object pixel
Returns:
true
if should be,false
otherwise
- Type
- boolean
-
<async, protected> _loadImg(imgPath, imgOpts)
-
Loads image.
Parameters:
Name Type Description imgPath
string path loaded image
imgOpts
object image options
Returns:
- image data
- Type
- Promise.<object>
-
<async, protected> _saveMatchImage(left, top, width, height)
-
Saves matched part of image.
Parameters:
Name Type Description left
number offset from left image border
top
number offset from top image border
width
number width of matched part
height
number height of matched part
Returns:
- Type
- Promise.<void>
-
_transpose(pixels)
-
Transposes pixels matrix.
Parameters:
Name Type Description pixels
Array.<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 dstPath
string path to potentially equal image
dstOpts
object <optional>
included image options
Properties
Name Type Argument Default Description tolerance
number <optional>
0.05 comparison tolerance
diffPath
string <optional>
<nullable>
null path to save captured difference.
saveDiff
boolean <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 dstPath
string path to potentially included image
dstOpts
object <optional>
included image options
Properties
Name Type Argument Default Description tolerance
number <optional>
0.05 comparison tolerance
matchedPath
string <optional>
<nullable>
null path to same captured place
saveMatch
boolean <optional>
false flag to capture images intersection or no
Returns:
- result
- Type
- Promise.<object>
-
<async> isBlack()
-
Defines whether processed image is black.
Returns:
true
if image is black,false
otherwise.
- Type
- Promise.<boolean>
-
<async> isMonochrome()
-
Defines whether processed image is monochrome.
Returns:
true
if image is monochrome,false
otherwise.
- Type
- Promise.<boolean>
-
<async> isTransparent()
-
Defines whether processed image is transparent.
Returns:
true
if image is transparent,false
otherwise.
- Type
- Promise.<boolean>
-
<async> isWhite()
-
Defines whether processed image is white.
Returns:
true
if image is white,false
otherwise.
- Type
- Promise.<boolean>