Requirements
Install the toolchain required by node-gyp:
- Windows
- A supported Visual Studio C++ toolchain.
- Python 3.
- macOS
- Xcode Command Line Tools.
- Python 3.
- Linux
- Python 3.
make.- A C/C++ compiler such as GCC.
- X11 development libraries (
sudo apt-get install libxtst-devon Ubuntu).
Build
From a RobotJS source checkout:
npm install
npm run build
BMP image loading and saving is included in every build.
Optional PNG support
PNG loading and saving is optional for source builds on macOS and Linux. Install libpng and pkg-config first:
# macOS
brew install libpng pkg-config
# Ubuntu or Debian
sudo apt-get install libpng-dev pkg-config
Enable PNG while rebuilding RobotJS:
ROBOTJS_ENABLE_PNG=1 npm run build
Check support at runtime instead of assuming it is present:
const robot = require("robotjs");
if (!robot.image.supportsPNG) {
throw new Error("This RobotJS build does not include PNG support.");
}
const image = robot.image.load("./target.png");
image.save("./copy.png");BMP remains available when PNG support is disabled. Loading or saving a .png file in that build throws an error.