Offset Polygon Bounds
Grow or shrink a panel — the node that makes the gutters between panels
- polygon
- bbox_snap
- POLYGON
Offset Polygon Bounds is the panel-shaping workhorse of comfyui-panels. It expands or erodes a panel polygon by a fixed pixel distance - and with the optional bounding-box constraint, it's the node that turns a raw cut layout into a page that actually looks like a comic, with gutters between panels and breathing room around the edges.
The core operation is a shapely buffer: positive offset expands the polygon outward, negative erodes it inward. The node description gives you the vocabulary - "expand" for positive, "erode" for negative. The default offset is -32, and that negative default is a hint about the most common use: after Build Layout Panels produces panels that sit edge-to-edge, you erode each one by a few dozen pixels to carve the gaps. That's your gutter width.
Inputs:
- polygon - the panel to adjust.
- offset - pixels to expand (positive) or erode (negative), -1000 to 1000, step 0.5.
- bbox_snap (optional) - a BBOX_SNAP constraint, created by the BBoxSnap node. This is where it gets interesting: it lets you anchor vertices to (or away from) the canvas edges so the buffer doesn't pull the page borders inward. The BBoxSnap node's
snap_iftoggle picks which behavior - snap vertices on the canvas edge so they stay put (good for adding space between panels), or snap vertices off the edge so only the border vertices move (good for adding page margins). Without this input, the buffer just happens to all vertices equally.
Output is a single POLYGON, ready to chain into more adjustments or feed a mask node.
The mental model that makes it click: think of this as "inset/outset," like a vector tool's inset path. Erode all panels slightly and you get clean gutters. Expand one panel to bleed past a neighbor and you get a dramatic full-bleed panel - a classic manga move where one action panel breaks out of the grid. Because it operates per-polygon, you can apply different offsets to different panels: shrink the quiet panels, explode the dramatic one.
Two real-world notes. First, aggressive erosion on a weird-shaped panel can make shapely collapse the geometry - the buffer returns an empty polygon and downstream nodes will complain. Erode in steps if you're pushing large values. Second, the bbox_snap machinery exists precisely because people kept fighting the border problem: if your page margins keep shrinking when you adjust panels, you're buffering without a snap constraint. Feed a BBoxSnap built from your canvas polygon and the borders behave.
Installing
Part of comfyui-panels by bmad4ever. Via ComfyUI Manager (search "comfyui-panels") and restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_panels
Deps: shapely, matplotlib, opencv-python - no models, no GPU, pure CPU geometry. Shapely is pinned exactly, so version clashes with other packs are the realistic import failure.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| polygon | POLYGON | — | |
| offset | FLOAT | -32.0-1000–1000 | The distance (in pixels) to offset the polygons' edges |
| bbox_snapopt | BBOX_SNAP | Constrain the adjustment operation with respect to a bounding box |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| POLYGON | POLYGON | — |