Skip to content

Comments

Add SplitImageToTileList and ImageMergeTileList nodes.#12599

Merged
comfyanonymous merged 1 commit intomasterfrom
temp_pr
Feb 24, 2026
Merged

Add SplitImageToTileList and ImageMergeTileList nodes.#12599
comfyanonymous merged 1 commit intomasterfrom
temp_pr

Conversation

@comfyanonymous
Copy link
Member

With these you can split an image into tiles, do operations and then combine it back to a single image.

With these you can split an image into tiles, do operations and then
combine it back to a single image.
@comfyanonymous comfyanonymous merged commit 9b1c63e into master Feb 24, 2026
14 of 15 checks passed
@comfyanonymous comfyanonymous deleted the temp_pr branch February 24, 2026 02:01
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

This pull request adds two new image processing nodes to the ComfyUI image utilities. The first node, SplitImageToTileList, divides an input image into a list of tiles using configurable width, height, and overlap parameters. The second node, ImageMergeTileList, reconstructs a single image from a tile list with specified dimensions and overlap handling. Both nodes share grid coordinate generation logic and implement per-tile weighting using sine-based masks for blending. The math module is imported to support the weighting calculations. The updated node registry exposes both new nodes publicly.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main change: adding two new image tile manipulation nodes to the codebase.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of the two new nodes and how they work together for tile-based image operations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_extras/nodes_images.py`:
- Around line 735-737: In execute (and before calling get_grid_coords) validate
that overlap is strictly less than both tile_width and tile_height (or clamp it
to a safe value like min(tile_dim-1, overlap)); if invalid, raise a clear
ValueError mentioning tile_width/tile_height and overlap to fail fast, or
silently clamp overlap to a computed safe stride and document that
behavior—update the execute signature logic around image, tile_width,
tile_height, overlap to perform this check and then call get_grid_coords with
the validated/clamped overlap.
- Around line 796-808: The code currently reads image_list[0] unsafely and can
silently produce black regions when tiles are missing or mismatched; update the
execute method to validate inputs: first assert image_list is non-empty and
raise a clear ValueError if empty, then read first_tile = image_list[0] and
capture its shape/device/dtype, call cls.get_grid_coords(w,h,t_w,t_h,ovlp) as
now, and then verify len(image_list) == len(coords) raising a descriptive error
if not; also iterate the tiles in image_list and validate each has the same
batch/channel dims, identical t_h/t_w (or compatible), device and dtype as
first_tile and raise a ValueError listing the offending index(s) if any mismatch
is found so the method fails fast instead of producing silent corruption.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a7debc and 022d3d7.

📒 Files selected for processing (1)
  • comfy_extras/nodes_images.py

Comment on lines +735 to +737
def execute(cls, image, tile_width, tile_height, overlap):
b, h, w, c = image.shape
coords = cls.get_grid_coords(w, h, tile_width, tile_height, overlap)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Validate overlap against tile size to prevent runaway tiling.
When overlap >= tile_width/height, stride collapses to 1, exploding tile counts (e.g., tile_width=64 with default overlap=128). Add a guard to fail fast or clamp.

🛡️ Proposed guard
     `@classmethod`
     def execute(cls, image, tile_width, tile_height, overlap):
+        if overlap >= tile_width or overlap >= tile_height:
+            raise ValueError("overlap must be smaller than tile_width and tile_height")
         b, h, w, c = image.shape
         coords = cls.get_grid_coords(w, h, tile_width, tile_height, overlap)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy_extras/nodes_images.py` around lines 735 - 737, In execute (and before
calling get_grid_coords) validate that overlap is strictly less than both
tile_width and tile_height (or clamp it to a safe value like min(tile_dim-1,
overlap)); if invalid, raise a clear ValueError mentioning
tile_width/tile_height and overlap to fail fast, or silently clamp overlap to a
computed safe stride and document that behavior—update the execute signature
logic around image, tile_width, tile_height, overlap to perform this check and
then call get_grid_coords with the validated/clamped overlap.

Comment on lines +796 to +808
def execute(cls, image_list, final_width, final_height, overlap):
w = final_width[0]
h = final_height[0]
ovlp = overlap[0]
feather_str = 1.0

first_tile = image_list[0]
b, t_h, t_w, c = first_tile.shape
device = first_tile.device
dtype = first_tile.dtype

coords = cls.get_grid_coords(w, h, t_w, t_h, ovlp)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fail fast on empty or mismatched tile lists.
image_list[0] will throw on empty input, and mismatched counts silently create black regions. Add validation to avoid silent corruption.

🧪 Suggested validation
     `@classmethod`
     def execute(cls, image_list, final_width, final_height, overlap):
+        if not image_list:
+            raise ValueError("image_list is empty")
         w = final_width[0]
         h = final_height[0]
         ovlp = overlap[0]
         feather_str = 1.0
@@
         coords = cls.get_grid_coords(w, h, t_w, t_h, ovlp)
+        if len(image_list) != len(coords):
+            raise ValueError(f"Expected {len(coords)} tiles, got {len(image_list)}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy_extras/nodes_images.py` around lines 796 - 808, The code currently
reads image_list[0] unsafely and can silently produce black regions when tiles
are missing or mismatched; update the execute method to validate inputs: first
assert image_list is non-empty and raise a clear ValueError if empty, then read
first_tile = image_list[0] and capture its shape/device/dtype, call
cls.get_grid_coords(w,h,t_w,t_h,ovlp) as now, and then verify len(image_list) ==
len(coords) raising a descriptive error if not; also iterate the tiles in
image_list and validate each has the same batch/channel dims, identical t_h/t_w
(or compatible), device and dtype as first_tile and raise a ValueError listing
the offending index(s) if any mismatch is found so the method fails fast instead
of producing silent corruption.

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