Crop Image
Crop by margins, not absolute coordinates, and never blow the bounds
- image
- image
Crop Image does exactly what it says - takes an image, crops it, returns the cropped image - but with one design decision that makes it friendlier than it looks: the four coordinates are margins measured from each edge, not absolute pixel positions. left crops from the left edge, top from the top, right from the right edge, bottom from the bottom. Crop 100px off the bottom by setting bottom: 100, no arithmetic about the image height required.
That's the "crop by margins" convention, and it's the right one for most workflows because it's stable across image sizes. The same node configuration crops a 1024×1024 and a 2048×2048 image identically as proportions of the border - you don't need to know the dimensions to express "trim the edges." The mechanism is a straight tensor slice, but the pack's implementation does a good job of defending you from yourself: it clamps negative values to zero and keeps the crop inside the image bounds even if your margins are absurd (left + right wider than the image collapses to a 1px sliver instead of crashing the graph).
The inputs are image plus four integers: left, top, right, bottom, all defaulting to 0. Output is the cropped image. That's the whole node. There's no aspect-ratio preservation, no smart centering, no crop-to-target-size - this is the dumb, precise version you use when you know exactly what to cut, or when you're feeding coordinates from another node (a bounding-box output, a face-detector, a manual mask inspection). If you want smart behavior - fill/crop to a target size with aspect handling - that's Cubiq Image Resize's fill / crop method in the same pack, which crops and resizes in one step.
Where beginners trip: the default of 0 on everything means "crop nothing," which is correct and harmless - you can wire an image through it as a no-op. And remember right/bottom are from the far edges, so right: 50 keeps the rightmost 50 pixels? No - it removes the rightmost 50. All four values are amounts removed, not positions kept. Get that backwards once and you'll crop the wrong side, but the clamping means the worst case is a small slice, not an error.
Install
ComfyUI Manager → search Sage Utils → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils.git
cd ComfyUI_SageUtils && pip install -r requirements.txt
Restart ComfyUI. Pure image utility, no models, no extra deps beyond the pack's dynamicprompts. It shows up under Sage Utils → image → manipulation.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | The image to crop. | |
| left | INT | 0 | The left coordinate for cropping. |
| top | INT | 0 | The top coordinate for cropping. |
| right | INT | 0 | The right coordinate for cropping. |
| bottom | INT | 0 | The bottom coordinate for cropping. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | The cropped image. |