To learn more about using JavaScript in LeanFT, see Setting up and working with the JavaScript SDK.
For JavaScript code samples, see Code Samples - JavaScript.

ImageUtils

ImageUtils. ImageUtils

new ImageUtils()

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

Methods

compareImages(firstImage, secondImage, maskAreaImage, pixelToleranceopt, rgbToleranceopt) → {Promise.<Boolean>}

Checks whether two images are a match, given the specified pixel and RGB tolerance values.
Parameters:
Name Type Attributes Description
firstImage String A Base64 string representation of the expected image.
secondImage String A Base64 string representation of the image to compare to the expected image.
maskAreaImage String A Base64 string representation of the image to compare to the expected image.
pixelTolerance Number <optional>
The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.
rgbTolerance Number <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 Boolean indicating if the images match.
Type
Promise.<Boolean>

getText(image, textAreaopt) → {Promise.<string>}

Returns all text within the supplied image.
Parameters:
Name Type Attributes Description
image String A Base64 string representation of the image to use for the search.
textArea Object <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, similarityopt) → {Promise.<object>}

Locates an image inside the provided source image.
Parameters:
Name Type Attributes Description
sourceImage String A Base64 string representation of the source image to check.
imageToFind String A Base64 string representation of the image to locate within the sourceImage.
similarity Number <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, rectangleopt) → {Promise.<object>}

Returns all rectangular areas within the supplied image that contain the specified text.
Parameters:
Name Type Attributes Description
image String A Base64 string representation of the image to use for the search.
textToFind String The text to search for in the test object.
rectangle Object <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>