feat: Implement basic text overlay node (CORE-137)#14610
Conversation
Overlay text along the top of an image or image batch (video) without resizing it. Takes just an image and the text; the font scales with resolution and wraps to fit, long text fills and overflows rather than truncating, and a translucent banner with a contrasting outline keeps it legible on any background. CORE-137
34ec04d to
d8711f0
Compare
📝 WalkthroughWalkthroughA new file 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_extras/nodes_text_overlay.py`:
- Around line 125-126: The text wrapping logic in the overlay renderer is
collapsing user-entered whitespace because `split()` is used in the loop inside
`nodes_text_overlay.py`, which destroys repeated spaces and tabs before drawing.
Update the wrapping path in the text processing function that iterates over
`raw_line` so it preserves literal spacing and tab characters from the original
caption instead of tokenizing on all whitespace; keep the existing `\t` handling
from the earlier text normalization intact while changing the wrapping
implementation to work with the raw line content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bb2ee910-d7f8-4730-87c9-8287e7f216af
📒 Files selected for processing (2)
comfy_extras/nodes_text_overlay.pynodes.py
| for raw_line in text.split("\n"): | ||
| words = raw_line.split() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve literal spacing when wrapping text.
Line 126 uses split(), which collapses repeated spaces and removes tabs. That rewrites the user’s caption before rendering, so indentation, double-spaces, and the escaped \t handling from Line 37 never survive to the image.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comfy_extras/nodes_text_overlay.py` around lines 125 - 126, The text wrapping
logic in the overlay renderer is collapsing user-entered whitespace because
`split()` is used in the loop inside `nodes_text_overlay.py`, which destroys
repeated spaces and tabs before drawing. Update the wrapping path in the text
processing function that iterates over `raw_line` so it preserves literal
spacing and tab characters from the original caption instead of tokenizing on
all whitespace; keep the existing `\t` handling from the earlier text
normalization intact while changing the wrapping implementation to work with the
raw line content.
Implements a basic native Text Overlay node:
Currently uses standard built-in PIL default font and draws an overlay with an outline on top of the image or video at the desired position. Compatible with newline escape characters (
\n).Example workflow that creates a grid of test images with different settings:
droz_textoverlay_test_C137_1.json
Image example:
Video example: