Badge Route 2 Canvas V1 (DAELab)
The boring 1024 normalize that stops masks drifting
- effect_image
- canonical_master
- direct_selection_reference
- edit_support_mask
- status
One input, four outputs, no model, no API key, no settings. On paper this is the least interesting node in the pack. In practice it's the one that decides whether the rest of a badge workflow lands on the right pixels, because every other node in that pipeline silently assumes a 1024×1024 square canvas - the material channels hard-code 1024, the structure constraint refuses anything else, the ID maps are cached as 1024 squares.
Upload anything not exactly square - a 3:2 product shot, a screenshot, a render straight out of the GPT Image 2 partner node at some other size - and without this node you get mask/shape errors or, worse, masks that are all the right shape and slightly the wrong place.
What "normalize" means here
effect_image goes in. The node refuses batches ("Route 2 requires exactly one uploaded effect image") which is the correct amount of strictness for an upload-shaped node.
Inside, it does the most standard thing possible: scale the image by min(1024/w, 1024/h) with bicubic interpolation so the longest side fits, then centre it on a 1024 square canvas filled with white. The leftover letterbox area isn't just white paint - the node reports the offset and scale it used, and derives the edit-support mask from it.
Alpha handling is the interesting bit. If the image has an alpha channel, alpha > 0.5 becomes the support mask, and the RGB is composited over white so you don't get black fringes where the transparency was. If there's no alpha, the support mask is simply "the letterboxed content rectangle" - 1 inside, 0 in the padding. Either way, edit_support_mask means these pixels are actually your badge.
The four outputs
canonical_master- the 1024 square, white-padded, alpha-flattened image. This is what everything downstream should be looking at.direct_selection_reference- a clone of the same tensor, intended for the selection UI so that picking coordinates doesn't depend on the master being re-read.edit_support_mask- the content mask described above. Multiply it into any selection mask before a paid local edit and you physically cannot spend a credit repainting the letterbox.status- a JSON string withsource_canvas,resized_canvas,offset,scaleand the alpha policy used (source_alphavsvalid_letterbox_content). Read it when something looks off; it tells you exactly what the geometry did. It's also where "ready" lives, so a dashboard widget can show it.
That status string is the closest thing to a UI here, so wire it into a text display node if you're building an App Mode panel. It costs nothing and it answers the question "why did my 16:9 image come out with white bars."
Where it belongs in a graph
Put it immediately after your upload/loader and before anything that assumes a square: the render-space mask alignment node, the material region channels, the structure constraint, the color-lock composite. If you're building the pack's #8.6 - Badge Workflow style pipeline, this is the front door of the "route 2" branch - the path where the user brings their own finished effect render instead of generating one.
White padding is a deliberate choice rather than a bug: white is what the studio background stage is trying to produce anyway, and it means a badge photographed on white blends instead of sitting in a black frame. If your render has a strong coloured backdrop, the alignment node's auto_border extraction is going to see that backdrop as "background" anyway, which is usually what you want.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library.git
Restart ComfyUI after cloning, and refresh the browser tab. If you install through ComfyUI Manager, search the pack title - the node will show up under DAELab/Badge/App once the pack loads. Don't copy single node folders out of the repo; registration happens in the root __init__.py and the front-end assets live in a shared web/ directory.
Gotchas
The node itself is pure PyTorch, but it lives in the same Python module as the pack's badge app routing code, which imports OpenCV at the top. So a broken/absent cv2 can take this node down with it even though it never touches OpenCV. If the whole DAELab/Badge/App category is missing from your node list, check the ComfyUI startup log for No module named 'cv2' and install opencv-python-headless into the same Python environment ComfyUI runs in. requirements.txt in the repo will not do it for you - it only lists the three document-parsing libraries.
Second, don't queue a batch through it hoping to normalize a folder of images. One image per run. Loop with a batch loader upstream and a normalizer per item, or you'll get the explicit batch error and nothing else.
Third: because the canvas is centred and letterboxed rather than cropped, a very wide image ends up as a small band in the middle of a big white square. That's geometrically honest and it keeps your polygons alignable, but it also costs you resolution. Crop first if you care about detail.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| effect_image | IMAGE | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| canonical_master | IMAGE | — |
| direct_selection_reference | IMAGE | — |
| edit_support_mask | MASK | — |
| status | STRING | — |