Get Margin Extra
Put your trim margins back on the wire
- extras
- margin
- top
- right
- bottom
- left
Get Margin Extra reads a stored trim margin out of an image's image_info extras and hands it back both as a bundled margin value and as individual top, right, bottom, and left integers. It's the read side of the pack's margin workflow, paired with Set Margin Extra - and it exists because of a genuinely good idea: sample a little bigger than you want, then trim the excess, which keeps your final size exact while letting the model work on a comfortably aligned canvas.
The margin workflow it belongs to
The pack's Aspect Ratio to Size (Trim Margin) computes a sampling size that's intentionally larger than your target, keeping the four margin values linked so each opposite pair sums to zero or the mini_unit. Trim Image by Margin then crops those edges off after generation. The Set/Get margin extras close the loop: store the computed margins in image_info via Set Margin Extra, and when that image_info is saved, restored, or passed through another image-info node, Get Margin Extra reconstructs the bundled margin plus all four edge values.
Why bother storing them at all? Because the margin set isn't something you want to recompute by hand in every branch of a workflow - and because, when the image comes back through Image Reader, the trim parameters come back with it. Trial results carry into the next pass, which is the pack's entire philosophy.
Inputs and outputs
Inputs are the family standard:
extras- theIPT-ImageInfoExtrassocket.key- the parameter-line key the writer used.
Outputs:
margin- the bundledIPT-Margin, ready forTrim Image by Margin.top,right,bottom,left- the fourINTedge values, if you need them individually for anything else.
When margin is unconnected, the pack's trim node passes the image through unchanged - which is a graceful way to fail, but it also means a missing key can silently skip your trim. Check the writer side if your output suddenly has borders.
Installing it
Ships in the ComfyUI-Info-Prompt-Toolkit pack. Via ComfyUI Manager - search "Info Prompt Toolkit" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
cd comfyui-info-prompt-toolkit
pip install -r requirements.txt
Restart ComfyUI. No model downloads for this node. It's a small single-author pack (GPL-3.0) without a big community footprint, so expect the margin-specific parts of it to be opinionated - which is fine when you're already buying into its image-info conventions.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| key | STRING | Parameter line key | |
| extrasopt | IPT-ImageInfoExtras | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| margin | IPT-Margin | — |
| top | INT | — |
| right | INT | — |
| bottom | INT | — |
| left | INT | — |