Smart Crop πͺ½
Crop by dragging, not by guessing pixel numbers
- image
- image
Smart Crop is ComfyAngel's "stop dialing in coordinates" answer to the crop node. Most crop nodes in ComfyUI make you type x, y, width and height, run, squint at the result, and change a number. This one opens a dialog where you drag a rectangle over a preview of the image and it writes the numbers back into the widgets for you. The position, size, and even a crop that hangs off the edge of the image are all set by mouse instead of arithmetic.
Reach for it any time you need a region of a finished image: slice out a face before a detailing pass, trim letterboxing before you composite, or grab a strip to feed an upscaler. It's a deterministic pixel operation - no model involved - which is exactly the kind of thing you want to do for free in milliseconds rather than by burning another diffusion pass.
How it works
The Python side is refreshingly plain: it builds an output canvas crop_width Γ crop_height, fills it with bg_color, and copies in the overlap between your crop rectangle and the source image. The clever part is the JavaScript widget (crop_widget.js) that adds an "Open Crop Editor" button to the node. Click it and you get the drag-to-select dialog with aspect-ratio presets and a live rectangle; when you commit, it pushes the values into the x, y, crop_width, and crop_height widgets and you run. You get the pixel-accurate behavior of a scripted crop with the hand-feel of Photoshop.
The inputs and outputs that matter
image- the IMAGE to crop. Works on a batch: the same rectangle is applied to every frame.x/y- top-left corner of the crop. These can go negative, which is the secret to cropping beyond the left or top edge (the out-of-bounds area becomesbg_color).crop_width/crop_height- size of the output, default 512 Γ 512.bg_color- optional, default#000000. Fills anywhere the crop rectangle extends past the image bounds.#FFFshorthand works too.
Output is a single image output: the cropped tensor, still in a batch with dimension 1.
Where people get burned
The default is a 512Γ512 crop at (0,0). Wire this up without opening the editor and you get the top-left quarter of a 1024 image, or a mostly-black region if your image is smaller than the box. Two gotchas follow from the "crop beyond the edge" behavior: a negative x or y silently turns into a black border unless you set bg_color deliberately, and the same goes for a crop that overhangs the right or bottom edge. When you're compositing the result, black versus white filler changes how the seams look, so pick the color on purpose.
It's part of the ComfyAngel pack, which means it ships alongside the visual sibling nodes (Smart Composite, Color Picker, Resolution Picker) - all the "don't make me type a number" conveniences in one install.
Installing
From the ComfyUI Manager, search for ComfyAngel and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ThepExcel/ComfyAngel
Then restart ComfyUI. There's also comfy node install comfyangel if you use the CLI/registry. The only dependency is Pillow - no model files to download, nothing heavy.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| x | INT | 0-8192β8192 | β |
| y | INT | 0-8192β8192 | β |
| crop_width | INT | 5121β8192 | β |
| crop_height | INT | 5121β8192 | β |
| bg_coloropt | STRING | #000000 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |