Skip to content

Add Pad Image node with mirror padding and pad to multiple - #17224

Merged
alexisrolland merged 3 commits into
Comfy-Org:masterfrom
DoronGenzelHass:pad-image-node
Oct 21, 2026
Merged

alexisrolland merged 3 commits into
Comfy-Org:masterfrom
DoronGenzelHass:pad-image-node

Conversation

@DoronGenzelHass

Copy link
Copy Markdown
Contributor

Models like LTX need width/height to be multiples of 32. Padding then cropping back keeps the exact resolution, but the core pad nodes only pad with a solid color, which models turn into hard edges. Mirror padding works much better.

Adds a Pad Image node (PadImageNode) as agreed in :

  • padding_type: pad dimensions, pad by multiplier, pad to multiple
  • padding_style: color (with feathering), mirror image

Keeps the input dtype and device, with no clamping, so HDR values pass through. Existing pad nodes are unchanged.
Tests: tests-unit/comfy_extras_test/pad_image_test.py, plus manual testing in the frontend.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Comfy-Org/ComfyUI/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5bb14925-aa58-4397-b923-d14836ddfc10
📥 Commits

Reviewing files that changed from the base of the PR and between c22e4f4 and 887fc48.

📒 Files selected for processing: 1
  • comfy_extras/nodes_images.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 10
  • GitHub Check: Run Pylint
  • GitHub Check: test
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-24.04-arm)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (windows-2022)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-24.04-arm)
  • GitHub Check: test (windows-latest)
🧰 Additional context used
📚 Code guidelines: 1
AGENTS.md — configured
📓 Path-based instructions: 3
Community-contributed extra nodes.

⚙️ CodeRabbit configuration file

Files:

  • comfy_extras/nodes_images.py
IMPORTANT: Only comment on issues directly introduced by this PR's code changes.

⚙️ CodeRabbit configuration file

Files:

  • comfy_extras/nodes_images.py
Source excerpt: Keep changes small and direct.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • comfy_extras/nodes_images.py
🔀 Multi-repo context Comfy-Org/ComfyUI_frontend, Comfy-Org/comfy-kitchen

Linked repositories findings

Comfy-Org/ComfyUI_frontend

  • Node definitions are fetched dynamically from /object_info and returned as backend-provided definitions, so PadImageNode does not require a coordinated frontend registration change. [::Comfy-Org/ComfyUI_frontend::src/scripts/api.ts:1266-1269]

Comfy-Org/comfy-kitchen

  • The related padding operation is specialized 3D GroupNorm/SiLU processing with spatial reflection or zero padding, not a general 2D image-padding API. [::Comfy-Org/comfy-kitchen::comfy_kitchen/init.py:361-384]
  • Its other padding support targets tensor quantization divisibility, such as MXFP8 dimensions divisible by 32, rather than color, feathering, or image-edge padding. [::Comfy-Org/comfy-kitchen::comfy_kitchen/init.py:557-572]

No cross-repository implementation or rollout change appears necessary.

🔇 Additional comments: 1
comfy_extras/nodes_images.py: 1

21-21: LGTM!

Also applies to: 23-23, 29-29, 652-790, 2274-2274

📝 Walkthrough

Adds a registered PadImageNode that pads images by explicit side dimensions, a multiplier, or a requested multiple. The node supports mirrored-edge and solid-color padding, including optional feathering for color fills. Padding helpers split odd totals across opposing sides and support reflection beyond image dimensions. Unit tests cover padding modes, output values and dimensions, dtype and alpha handling, feathering, and identity behavior when no padding is needed.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 887fc

The reviewed padding behavior presents no identified merge-blocking issue; the change is ready for normal merge checks.

Security architecture risk: 🔵 Low · up to 887fc

The new node stays within existing image-processing capabilities and does not introduce additional access to files, networks, or credentials. Large allocations remain possible, but comparable image expansion already exists. Request validation and deployment-level resource isolation were not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct resource sink is tensor memory on the input image's device. A workflow author controls output dimensions and can request large allocations; any effect on other workloads depends on worker and device isolation that was not established by the inspected source.

Security Findings and Attack Paths

  • inferred — The lack of an absolute output-size cap is not established as a new allocation attack capability. At the PR base, publicly registered ImageScaleBy already accepted an 8x multiplier and passed the resulting dimensions to interpolation without an absolute cap; ImagePadForOutpaint already exposed additive per-side expansion. These paths provide stronger counterevidence than comparison with the fixed-target resize-and-pad node alone.

Trust Boundaries and Controls

  • inferred — The node adds a callable transformation within the existing extension boundary rather than a new identity or privileged-service transition. Numeric limits are declared in its schema, but their server-side enforcement was not verified and is not assumed here.

Resilience and Maintainability Implications

  • observed — The transformation does not write into caller-owned image data or publish persistent state. Color-fill writes and feathering affect only the newly allocated output; reflection reads the input, and the zero-padding path returns it without modification. Thus no shared-state commit or recovery protocol is introduced by this implementation.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the new PadImageNode, its padding modes, mirror padding, HDR preservation, and tests. It directly matches the changeset.
Title check Passed The title clearly identifies the new Pad Image node and its main mirror-padding and pad-to-multiple capabilities.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 20, 2026
@alexisrolland
alexisrolland merged commit f5c611e into Comfy-Org:master Oct 21, 2026
17 checks passed
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.

2 participants