Image Grab PIL
Pull a screen region straight into ComfyUI (local desktop only)
- image
This node captures a rectangle of your actual screen and feeds it into ComfyUI as an IMAGE - no webcam, no file, just whatever pixels are on your desktop at that region and moment. Combined with ComfyUI's auto-queue feature, that turns into a realtime, screen-reactive diffusion setup: point it at a window, a drawing app, a game, anything, and have a workflow re-run continuously on whatever's showing there.
One thing to get out of the way up front, because it matters specifically if you're reading this on comfy.icu: this needs a real desktop to capture from. It grabs pixels off an actual display via PIL's ImageGrab, which means it works on a local ComfyUI install running on your own machine, and it will not work against a headless cloud GPU worker with no display attached - which is how serverless platforms like this one run executors. If your workflow needs this node, it's a local-desktop tool, not a cloud-run one.
How it works
Given a screen coordinate and a size, it grabs that rectangular region using PIL's screen-capture capability and converts it straight into ComfyUI's image tensor format. It can optionally grab a short burst of consecutive frames rather than a single still, useful if you want a small motion sample rather than one snapshot.
The inputs and outputs that matter
x/y(both default 0) - the top-left corner of the capture region, in screen pixel coordinates.width/height(both default 512) - the size of the region to grab.num_frames(default 1, up to 255) - how many consecutive captures to take. 1 gets you a single still; higher values grab a short burst.delay(default 0.1, up to 10 seconds) - the pause between captures whennum_framesis more than 1.
Output is a single image - whatever was on screen in that region, ready to feed straight into an img2img pipeline or any node expecting an IMAGE.
How to install it
Via ComfyUI Manager: search "KJNodes for ComfyUI," install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
then restart. This node relies on PIL's screen-grab capability, which in turn needs an actual display session available to the process running ComfyUI - the base pack install is lightweight, but this specific node's functionality is only meaningful on a machine with a screen.
Common issues & troubleshooting
It errors or returns nothing on a server or cloud instance. This is expected, not a bug - there's no display for it to capture from. This node is built for local, desktop ComfyUI installs where you're pointing it at your own screen; it has no equivalent on headless GPU workers.
The captured region is offset from what you expected. Screen coordinates depend on your OS's display setup - multi-monitor arrangements and OS-level display scaling (fractional DPI scaling especially) can shift what x/y actually lands on. Test with a small, distinctive region first to calibrate before wiring it into a full realtime setup.
Realtime capture feels choppy or laggy. That's a function of how fast your workflow can sample plus your auto-queue interval, not this node itself - it's a fast, synchronous grab. If the pipeline downstream is slow, the screen capture will always be the least of your bottlenecks.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| x | INT | 00–4096 | — |
| y | INT | 00–4096 | — |
| width | INT | 5120–4096 | — |
| height | INT | 5120–4096 | — |
| num_frames | INT | 11–255 | — |
| delay | FLOAT | 0.100–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |