Image
nut.js enables you to search for images on your screen.
To represent image data, nut.js provides the Image
datatype.
#
Image PropertiesAn Image
holds all the data required to perform on-screen search.
That is:
- the image
width
- the image
height
- a buffer storing raw image
data
- the amount of color
channels
- an
id
#
ColorModeAdditionally, it also stores information about the order of color channels.
By default, nut.js images are stored using the BGR
color mode.
This mode was chosen to align with a well known computer vision library.
However, since not every image processing library expects image data in BGR
ordering, nut.js images provide methods to convert between BGR
and RGB
mode.
#
Image loadingnut.js provides helpers for image loading.
loadImage
receives a full path to an image, loads it and returns an Image
in BGR
color mode, representing this particular file.
The image id will automatically be set to the path it was loaded from.
#
imageResourcesOften times, images are loaded to be used as inputs to Screen#find
or similar.
For such use cases, nut.js provides the imageResources
helper function to load images relative to a configured resource directory.
See Loading Images from Resource Directory and the cross platform trick for further information.
#
Image savingSimilar to image loading, nut.js provides helpers for image saving as well.
saveImage
receives an ImageWriterParameters
object that consists of the following:
nut.js will take care of possibly required color mode conversions, so you, as a user, do not have to care about it.