Image Grab PIL(ImageGrabPIL)
This node is based on the `ImageGrab` module from Python's PIL (Pillow) library.
Image Grab PIL
The Image Grab PIL node is a screen capture tool that allows you to directly specify a rectangular area on your computer screen and capture an image of that region. Its core function is to acquire screen content in real-time and convert it into image data that can be processed by ComfyUI workflows. This makes it possible to quickly import any visual element from the screen into an AI image processing pipeline.
Node Function
This node is implemented based on the ImageGrab.grab method from Python's PIL (Pillow) library, capturing pixels by defining a bounding box of screen coordinates. The captured image data is automatically converted into PyTorch tensor format and normalized to a floating-point range of [0, 1] to comply with the standard IMAGE type in ComfyUI. Additionally, the node supports capturing multiple consecutive frames and allows for configurable delays between frames, providing a foundation for recording dynamic or changing screen content.
Node Parameter Description - Image Grab PIL
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
x | INT | Yes | 0 | 0 - 4096 (step: 1) | x (Input Parameter): Defines the horizontal coordinate (in pixels) of the top-left corner of the capture area. Value range 0 to 4096, step 1. |
y | INT | Yes | 0 | 0 - 4096 (step: 1) | y (Input Parameter): Defines the vertical coordinate (in pixels) of the top-left corner of the capture area. Value range 0 to 4096, step 1. |
width | INT | Yes | 512 | 0 - 4096 (step: 1) | width (Input Parameter): Defines the width (in pixels) of the capture area. Value range 0 to 4096, step 1. |
height | INT | Yes | 512 | 0 - 4096 (step: 1) | height (Input Parameter): Defines the height (in pixels) of the capture area. Value range 0 to 4096, step 1. |
num_frames | INT | Yes | 1 | 1 - 255 (step: 1) | num_frames (Input Parameter): Sets the number of consecutive frames to capture. Value range 1 to 255, step 1. |
delay | FLOAT | Yes | 0.1 | 0.0 - 10.0 (step: 0.01) | delay (Input Parameter): Sets the wait time (in seconds) between each frame when capturing multiple consecutive frames. Value range 0.0 to 10.0, step 0.01. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| image | IMAGE | image (Output Parameter): Outputs the captured screen image in the standard ComfyUI IMAGE type format (tensor). |
Use Cases
This node is very useful in real-time image generation or style transfer workflows. For example, you can connect it to a KSampler node to create a "real-time diffusion" loop: first capture a drawing or design sketch from the screen, then immediately have a Stable Diffusion model redraw or stylize it, and output the result back to the screen, forming an interactive creation loop. Combined with the automatic queue function, near real-time continuous processing can be achieved.
Notes
The capture range of this node is limited by the actual screen resolution. Although the parameter upper limit is set to 4096, the effective area should not exceed your monitor's boundaries. When capturing multiple frames, shorter delays and higher frame counts may increase system load. Please note that it can only capture visible content on the screen and cannot capture areas covered by other windows or minimized regions.
Image Grab PIL Node Source Code Link
The Image Grab PIL node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.