int - burn padding location as square (size)
The math for centering a crop on a square canvas
- left
- top
- right
- bottom
A common regional-prompting move is to pad a non-square region into a square one - and doing that by hand means deciding which side gets the pad and by how much, every single time. int - burn padding location as square (size) computes it for you: give it a width and height, and it returns the padding offsets that center your region on a square canvas.
It's the odd one out among the ymc pack's region helpers. The other three convert between crop-box representations; this one answers a different question: "my region is 512×384 (or 384×512) - where does the padding go to make it square?" The answer comes back as four integers: left, top, right, bottom.
How it works
The logic is: the target square side is the larger of the two dimensions, and the shorter axis gets the difference, split evenly on both sides so the content stays centered.
- If
w < h(portrait - taller than wide), the padding is horizontal:leftandrightboth get the same positive value,top/bottomstay zero. - If
w >= h(landscape or square), the padding is vertical:topandbottomget the same positive value,left/rightstay zero.
So a 384-wide, 512-tall region produces left = 64, top = 0, right = 64, bottom = 0 - the two horizontal pads that turn 384 into 512. The equal left/right or top/bottom split keeps your subject centered rather than shoved to one edge, and the values are always zero or positive (the shorter axis, by definition).
Those offsets then feed whatever crop/pad or "burn location" consumer your regional workflow uses. The node is pure integer arithmetic - no models, no GPU.
Inputs and outputs
w- region width (default256)h- region height (default256)- Outputs (
INT):left,top,right,bottom- the padding offsets
Note there's no cx/cy/w/h echo here - just the four padding values. That's the whole job.
Installing it
Part of ymc-node-suite-comfyui:
- ComfyUI Manager → search
ymc-node-suite-comfyui→ Install → restart, or
cd ComfyUI/custom_nodes
git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
restart, and pip install -r requirements.txt on a manual clone (four yors_* helper libs; the pack's auto-install is commented out). No models, no GPU.
Find it under the right-click ymc suite → text → region menu, or search the canvas for burn padding.
Common issues
- The outputs are padding amounts, not absolute positions. They're always zero or positive, and they mean "grow this side by this much." A
top = 64says the region needs 64px of pad above it to sit centered in the square - it does not mean "the top edge is at y=64." w == hreturns all zeros. A square region needs no padding; every output is0, which is correct and also easy to mistake for "nothing happened."- It computes; it doesn't crop. This node never touches an image. It produces the offsets; a pad/crop node does the work.
- WAS Node Suite conflicts on the pack's io/save nodes can appear as Manager warnings if you run both packs - unrelated to this node.
If what you actually wanted was a crop box converted between forms, the pack's three other region nodes (lt-size, center-size, cxcy-size) cover that; this one exists specifically for the square-padding case.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| w | INT | 2560–10000000 | — |
| h | INT | 2560–10000000 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| left | INT | — |
| top | INT | — |
| right | INT | — |
| bottom | INT | — |