ImageUtils

ImageUtils. ImageUtils

new ImageUtils()

An ImageUtils class for image utilities, such as OCR, image comparisons, and image find operations.

Methods

compareImages(firstImage, secondImage, pixelTolerance[opt], rgbTolerance[opt]) → {Promise.<boolean>}

Checks whether two images are a match, given the specified pixel and RGB tolerance values.
Parameters:
NameTypeAttributesDescription
firstImagestringA Base64 string representation of the expected image.
secondImagestringA Base64 string representation of the image to compare to the expected image.
pixelTolerancenumber <optional>
The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.
rgbTolerancenumber <optional>
The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.
Returns:
a promise that is fulfilled with a boolean indicating if the images match.
Type
Promise.<boolean>

compareImagesWithMask(firstImage, secondImage, maskAreaImage, pixelTolerance[opt], rgbTolerance[opt]) → {Promise.<boolean>}

Checks whether two images are a match, given the mask area image and specified pixel and RGB tolerance values.
Parameters:
NameTypeAttributesDescription
firstImagestringA Base64 string representation of the expected image.
secondImagestringA Base64 string representation of the image to compare to the expected image.
maskAreaImagestringA Base64 string representation of the mask area used for the comparison between the expected image and image to compare. This mask area is calculated based on the expected image and should have rectangle areas which specify which part of the image will be included or excluded from the comparison. The rectangle which should include the area in the comparison should be painted with white pixels. The rectangle which should exclude the area in the comparison should be painted with black pixels. If the full image is with white pixels means all the image will be included in the comparison. If the full image is with black pixels means all the image will be excluded in the comparison.
pixelTolerancenumber <optional>
The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.
rgbTolerancenumber <optional>
The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.
Returns:
a promise that is fulfilled with a boolean indicating if the images match.
Type
Promise.<boolean>

getImageLocations(sourceImage, imageToFind, similarity[opt]) → {Promise.<Array.<Object>>}

Returns the first 100 locations of an image inside the source image. If the number of images found exceeds 100 images, a GeneralReplayException is thrown.
Parameters:
NameTypeAttributesDescription
sourceImagestringA Base64 string representation of the source image to check.
imageToFindstringA Base64 string representation of the image to locate within the sourceImage.
similaritynumber <optional>
The minimum similarity between the two images (as a percentage), above which the find is considered a match. Default = 100.
Returns:
a promise that is fulfilled with an array of objects representing the point where the image was located.
Type
Promise.<Array.<Object>>

getText(image, textArea[opt]) → {Promise.<string>}

Returns all text within the supplied image.
Parameters:
NameTypeAttributesDescription
imagestringA Base64 string representation of the image to use for the search.
textAreaObject <optional>
An inner rectangle within the image.
Returns:
a promise that is fulfilled with all the visible text from the image.
Type
Promise.<string>

locateImage(sourceImage, imageToFind, similarity[opt]) → {Promise.<Object>}

Locates an image inside the provided source image.
Parameters:
NameTypeAttributesDescription
sourceImagestringA Base64 string representation of the source image to check.
imageToFindstringA Base64 string representation of the image to locate within the sourceImage.
similaritynumber <optional>
The minimum similarity between the two images (as a percentage), above which the find is considered a match. Default = 100.
Returns:
a promise that is fulfilled with an object representing the point where the image was located, or null if it was not found.
Type
Promise.<Object>

locateText(image, textToFind, rectangle[opt]) → {Promise.<Object>}

Returns all rectangular areas within the supplied image that contain the specified text.
Parameters:
NameTypeAttributesDescription
imagestringA Base64 string representation of the image to use for the search.
textToFindstringThe text to search for in the test object.
rectangleObject <optional>
An inner rectangle within the image.
Returns:
a promise that is fulfilled with rectangles array containing all rectangular areas containing the specified text within this image.
Type
Promise.<Object>