Nodes/comfyui-image-round/Crop Image (Advanced)
ComfyUI Node

Crop Image (Advanced)

Crop Image (Advanced)

By cdb-boop·Created 2 years ago·Updated about a year ago· 14
Crop Image (Advanced)
  • images
  • images
crop_left0
crop_right0
crop_bottom0
crop_top0
crop_left_override0
crop_right_override0
crop_bottom_override0
crop_top_override0

Crop Image (Advanced) is the cleanup crew for the Round Image (Pad/Crop) (Advanced) node. Round Image pads your image up to a multiple of a number; this node takes the exact pad amounts it reports and slices them right back off, restoring the original canvas. Padding changes the dimensions, and sooner or later you want the original dimensions back - usually because you're compositing the result onto something that was built around the source size.

It's a dumb node in the best way. You hand it an image and four integers - crop_left, crop_right, crop_bottom, crop_top - and it removes that many pixels from each edge. That's the whole job. It does it with plain tensor slicing, same technique the pack's own crop mode uses internally, so it's instant and needs no model, no weights, nothing.

How it works

The math is deliberately boring. Each crop value is clamped at zero (negative crops are treated as "crop nothing"), and if all four are zero the node returns your image untouched - a no-op pass-through. Otherwise it slices crop_top rows off the top, crop_bottom off the bottom, crop_left off the left, crop_right off the right, in that order, and hands you the smaller image.

That's why it pairs so cleanly with Round Image (Advanced): that node's four INT outputs - also named crop_left, crop_right, crop_bottom, crop_top - are exactly the numbers this node wants. Wire them straight across and you get a pad-then-recover round trip where the numbers are computed for you instead of eyeballed.

Inputs and outputs

  • images - any IMAGE tensor, batched or single.
  • crop_left, crop_right, crop_bottom, crop_top - INT widgets, default 0. These are the pixel counts to remove.
  • crop_left_override, crop_right_override, crop_bottom_override, crop_top_override - optional inputs. When you wire something into one of these, it overrides the matching widget value.

Output is a single images IMAGE. That's it.

The override inputs are worth understanding because they're the "Advanced" part: the node is built so another node can compute and feed the crop amounts instead of you typing them. Leave them unconnected and the plain widgets rule.

Installing it

This node ships in comfyui-image-round by cdb-boop, a tiny pure-PyTorch pack - no dependencies beyond what ComfyUI already has, no model downloads. It isn't in the official Comfy registry yet (there's an open PR to add it), so Manager's search-by-name may miss it. Easiest path:

cd ComfyUI/custom_nodes
git clone https://github.com/cdb-boop/comfyui-image-round

Then restart ComfyUI. Or in ComfyUI Manager use "Install via Git URL" with that same https://github.com/cdb-boop/comfyui-image-round address.

Gotchas

  • It's flagged as an output node, so don't try to chain crops through it - feed it the original image and one set of crop values, read the result.
  • If you crop more than the image has (say, crop_top larger than the height), the slice silently comes out empty or tiny. The padding from Round Image is exact, but hand-typed numbers should stay below the image dimensions.
  • Since it only ever shrinks, use it after padding, not before - cropping first and padding after throws away pixels for nothing.

It's a one-trick node, but it's the trick that completes the round-trip, and when you're assembling a workflow where a model demanded a multiple-of-something canvas, that's exactly the box you're missing.

Categoryimage

Inputs (9)

NameTypeDefaultDescription
imagesIMAGE
crop_leftINT0
crop_rightINT0
crop_bottomINT0
crop_topINT0
crop_left_overrideoptINT0
crop_right_overrideoptINT0
crop_bottom_overrideoptINT0
crop_top_overrideoptINT0

Outputs (1)

NameTypeDescription
imagesIMAGE