Bart's Smart Load Image (Crop) ✂️
Bart's Smart Load Image
- IMAGE
- MASK
- width
- height
- filename
Cropping an image in ComfyUI is supposedly a solved problem, until you try it. You load the photo, drop an ImageCrop after it, then type pixel coordinates into three boxes and queue the graph to find out whether you guessed right - while the crop you actually want is a thumbnail somewhere else, at thumbnail scale.
Bart's Smart Load Image (Crop) ✂️ folds both halves into one node: pick the file, drag a box on the node's own preview, and only that region comes out. Class SmartLoadImage, category Bart's nodes/Image. No model, no network, nothing extra to install - it's Load Image with a real crop editor bolted on.
Why you'd reach for it
Two jobs, and both are about spending pixels where they matter.
Detail passes. A sharp eye, a clean hand, a readable logo - crop that region and render it at the model's native resolution and it beats regenerating the whole frame. Same lesson crop-and-stitch inpainting taught everyone: crop first, work small, composite back.
Reference prep. ControlNet inputs, IP-Adapter references and character sheets behave better at an aspect ratio the model was trained on instead of whatever your screenshot happened to be. Crop a square out of a wide photo, snap to 64, stop fighting the model.
How it works, and where the illusion breaks
The editor writes four plain integers - crop_x, crop_y, crop_width, crop_height, in pixels of the original image - and those four numbers are the entire crop state. The server applies the box per frame, after EXIF rotation (the same rotation the browser used to draw the preview), before the tensor is built. Nothing downstream ever sees the pixels you cut away.
aspect_lock and snap_to are frontend helpers only. They shape the box while you drag; the server never reads them. So if you convert crop_width into an input and drive it from a math node, no lock enforces anything at run time.
A crop_width or crop_height of 0 means "no crop" - the default. Forgiving on a fresh node, quietly wrong when a linked value computes to 0: you get the full frame, not an error. A box that hangs past the edge is clamped at the edge, so a saved crop survives the file being replaced by a smaller one.
The inputs and outputs that matter
image is a dropdown of files in ComfyUI's input folder, with a 📁 Upload image button and drag-and-drop (uploads land in input, like the stock node). The four crop numbers get filled by dragging. aspect_lock offers free, original, 1:1, 4:3, 3:4, 3:2, 2:3, 16:9, 9:16, 21:9, 9:21; snap_to offers 1 / 8 / 16 / 32 / 64. ⤢ Full image clears the crop, ▣ Fit aspect makes the largest centred box at the chosen ratio.
Out: IMAGE is the cropped part only. MASK is 1 - alpha of that part (all zeros without transparency - palette GIF/PNG8 transparency included). width and height are the cropped size in integers, and that's the sleeper feature: wire them into an Empty Latent or a resize node and your generation dimensions follow the crop instead of you retyping 471×337. filename is the base name, handy for save prefixes.
Install
One pack of nine node groups, not a single node. ComfyUI Manager, search Bart's or the repo name; or:
cd ComfyUI/custom_nodes
git clone https://github.com/bartenevve/comfyui-random-imageload-node comfyui-bart-nodes
Restart, then search bart in the node menu. No requirements.txt - the image nodes need torch, Pillow and numpy, which ComfyUI already ships - and each node family imports in isolation, so the heavy YuE2 audio setup can't take the image loaders down with it. Example graph: example_workflows/10_smart_load_image.json.
Set expectations: this is a small, quiet pack, not an ecosystem household name. Little chatter about it, but a README that says what was tested and what wasn't - rarer than it should be.
Where people get burned
- It crops, it doesn't resize. A 300×200 crop leaves as 300×200. Model wants 1024? Put a resize after it, or use
snap_toand frame a box close to the size you want. - Linked crop values make the preview lie. The editor always draws the widget's own numbers, so a linked crop shows the old box while the graph runs something else. Trust the
width/heightoutputs. - Picking a different file resets the crop to "no crop" - you'll re-frame for every shot in a series.
- The file dropdown is a snapshot. Copy an image into
ComfyUI/inputby hand and it won't be listed until you reload the page; uploading through the node adds it immediately. - Input folder only. For an arbitrary directory, the pack's Bart's Load Random Image 🎲 handles that - but it has no crop.
The editor has been driven with a mouse, not a finger: handles have 32px touch targets and a second pointer is ignored, but on a tablet expect some guessing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 1 options: example.png | |
| crop_x | INT | 00–65535 | — |
| crop_y | INT | 00–65535 | — |
| crop_width | INT | 00–65535 | — |
| crop_height | INT | 00–65535 | — |
| aspect_lockopt | COMBO | free | 11 options: free, original, 1:1, 4:3, 3:4, 3:2, +5 |
| snap_toopt | COMBO | 1 | 5 options: 1, 8, 16, 32, 64 |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| width | INT | — |
| height | INT | — |
| filename | STRING | — |