Canvas Transform
Crop and grow
- input_canvas_image
- transformed_canvas
Canvas Transform is the geometry node of the leocbehe/canvas pack: it grows a canvas before the model fills in the new area, or trims it back after. No sampling, no masking logic - just crop and pad, done the way the pack likes it.
What it does
Feed it any IMAGE (input_canvas_image) and pick an operation: crop slices pixels off the edges, grow pads them on. Either way the four margin_t / margin_b / margin_l / margin_r widgets decide how many pixels from the top, bottom, left, and right, each 0–4096 in steps of 8. The step matters: it keeps every dimension a multiple of 8, so whatever you hand downstream stays latent-friendly.
grow has four fill modes. constant (default) pads with a solid value - grow_fill_value, 0.0 to 1.0, where 0 is black and 1 is white. reflect, replicate, and circular mirror, repeat the edge pixels, or tile the image instead. replicate is the boringly useful one for outpaint prep: the model gets something to blend from rather than a hard color wall. Internally it's torch.nn.functional.pad with each mode, which is exactly as cheap as it sounds.
Where it fits
The KB's modern outpainting trick is to pad the canvas with a solid color and ask the instruction model to replace it - "remove the red padding and show what's behind it" is a real workflow people run. Canvas Transform is the padding half of that: grow the canvas by your target margin, then mask the empty region and generate. The crop half is just as useful after the fact: outpaint a region, then trim the ragged seam edges back off the final composite.
One honest caveat: this is a raw geometry node. It pads pixels; it does not know about masks or outpainting. You still have to mask the new area and run the sampler yourself, and if the untouched original must survive byte-for-byte while extending it, the community's dedicated crop-and-stitch tools handle that more cleanly than this pack's manual loop. Use Transform when you want the simplest possible "make the slab bigger / trim the slab" step.
Installing
Same pack, same story as the rest of the Canvas nodes. ComfyUI Manager → search "Canvas", or:
cd ComfyUI/custom_nodes
git clone https://github.com/leocbehe/canvas
Restart ComfyUI. No dependencies beyond what ComfyUI bundles, no model files, no keys. Like its siblings it's a brand-new personal project (version 0.0.1, GPL-3.0) - simple enough that it mostly just works, but young enough that you're testing it for the author.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| input_canvas_image | IMAGE | — | |
| operation | COMBO | crop | 2 options: crop, grow |
| grow_mode | COMBO | constant | 4 options: constant, reflect, replicate, circular |
| grow_fill_value | FLOAT | 0.000–1 | Value to fill new pixels with if grow_mode is 'constant' |
| margin_t | INT | 00–4096 | Number of pixels to crop/grow from the top of the canvas |
| margin_b | INT | 00–4096 | Number of pixels to crop/grow from the bottom of the canvas |
| margin_l | INT | 00–4096 | Number of pixels to crop/grow from the left of the canvas |
| margin_r | INT | 00–4096 | Number of pixels to crop/grow from the right of the canvas |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| transformed_canvas | IMAGE | — |