Skip to content

feat: add image search and bitmap I/O. - #784

Merged
octalmage merged 10 commits into
masterfrom
feat/imageSearch
Jul 24, 2026
Merged

feat: add image search and bitmap I/O.#784
octalmage merged 10 commits into
masterfrom
feat/imageSearch

Conversation

@octalmage

@octalmage octalmage commented Mar 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the image-search API planned for RobotJS 0.8.0.

  • Capture screens and display-specific rectangles as Image objects.
  • Load and save BMP images, with opt-in PNG support on macOS and Linux source builds.
  • Find, count, and click images using exact or tolerance-based matching.
  • Find, count, and read colors inside complete images or bounded search rectangles.
  • Convert capture coordinates to screen coordinates, including scaled and negative-origin displays.
  • Enumerate displays for multi-monitor capture.
  • Preserve the existing Bitmap export as an alias of Image.

API

const robot = require('robotjs');

const screen = robot.screen.capture();
const target = robot.image.load('./target.bmp');
const match = screen.findImage(target, { tolerance: 0.1 });

if (match) {
  screen.click(match, target);
}

Image also provides findImages, countImage, findColor, findColors, countColor, colorAt, save, toScreenPoint, and clickImage.

Verification

  • Cross-platform CI covers Linux, macOS, and Windows on Node 24/25.
  • PNG-enabled CI runs on Linux and macOS; Windows verifies the disabled path.
  • Local image/bitmap/screen suite: 49 specs, 0 failures, 1 expected pending spec.

@octalmage

Copy link
Copy Markdown
Owner Author

I've been testing these changes in a number of end-user software, like https://github.com/octalmage/pixelcolor and so far they're very stable. Still more testing needed but it's looking promising.

@octalmage octalmage changed the title wip: Image Search, Bitmap and PNG savings, and test/build updates. feat: add image search and bitmap I/O. Jul 24, 2026
@octalmage
octalmage marked this pull request as ready for review July 24, 2026 18:58
@octalmage
octalmage merged commit baf5616 into master Jul 24, 2026
11 of 15 checks passed
@octalmage
octalmage deleted the feat/imageSearch branch July 24, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant