Center Image ♾️Mixlab
Carve out one region on a canvas by margin, not by hand
- canvas
- grid
- mask
Mixlab has a whole subsystem built around a custom type called _GRID - a way of describing a rectangular region on a canvas that its own family of nodes (SplitImage, GridInput, GridOutput, GridDisplayAndSave) pass around and act on, mostly for regional-prompt layouts feeding GLIGEN. CenterImage is the manual, single-region entry point into that system: instead of automatically slicing a canvas into N even cells the way SplitImage does, you define exactly one region by how far it's inset from each edge.
How it works
You give it a canvas image and four margins - left, top, right, bottom - each in pixels. The node treats the canvas as a rectangle and shrinks it inward by those margins on each side, and that resulting inner rectangle becomes your region. It comes out as a _GRID (the same type the rest of the grid family trades in) plus a matching mask.
Think of it as marking "here's the middle bit I care about" on a template - a poster frame, a photo slot, the area you actually want to composite into - without doing pixel math yourself.
The inputs and outputs that matter
canvas(IMAGE, required) - the image whose dimensions define the outer rectangle.left/top/right/bottom(INT, default24each, range0–5000) - the margin to inset from each respective edge. Bigger numbers mean a smaller, more centered region.
Outputs: grid (_GRID) - the region descriptor, meant for sibling nodes like GridOutput (to turn it into real x/y/width/height) or GridDisplayAndSave (to preview and save it) - and mask, a plain mask of that same region for anything that just wants a MASK.
How to install it
Ships with the Mixlab pack.
- ComfyUI Manager: search
comfyui-mixlab-nodes, install, restart. - Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/shadowcz007/comfyui-mixlab-nodes.git, install requirements (install.baton Windows, or../../../python_embeded/python.exe -s -m pip install -r requirements.txt), restart.
No model downloads needed for this node specifically.
Common issues & troubleshooting
The region doesn't line up with what I expected. The margins are absolute pixels, not percentages - if you reuse the same CenterImage settings against a canvas of a different resolution, the region shifts relative to the image, since 24px means something very different on a 512px canvas versus a 4000px one. Match your margins to the actual canvas size you're working with, or recompute them if you change resolutions.
The grid output won't plug into anything. _GRID is Mixlab-specific - it only connects to the pack's own grid-aware nodes (GridOutput, GridDisplayAndSave, and GLIGEN's regional-apply node in this same pack), not generic image or crop nodes from elsewhere. If you need plain numbers, route the grid output through GridOutput first to get x/y/width/height.
I just want a rectangle mask, not the grid stuff. Use the mask output directly and ignore grid entirely - it's a completely valid way to use this node if all you want is "canvas minus a margin" as a mask for compositing or inpainting.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| canvas | IMAGE | — | |
| left | INT | 240–5000 | — |
| top | INT | 240–5000 | — |
| right | INT | 240–5000 | — |
| bottom | INT | 240–5000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| grid | _GRID | — |
| mask | MASK | — |