Shima Interactive Crop
Drag a box on the image, get a crop, a mask, and clean numbers
- image
- shima.commonparams
- cropped_image
- crop_mask
- crop_data
Region-based work - crop a face, fix a hand, feed one character into an IP-Adapter - always starts the same way: you need a rectangle, and you need its coordinates as numbers. Shima Interactive Crop is the friendly version of that. You drag a box over the image in the node, and out come three things at once: the cropped pixels, a mask marking exactly where that box was, and a dictionary of clean x/y/width/height data. No guessing, no measuring in a paint program.
How it works
The crop coordinates are normalized - crop_x, crop_y, crop_w, crop_h are all 0–1 fractions of the image, so the values stay stable if you swap in a different-sized source. The backend multiplies them by the actual pixel dimensions, slices the tensor, and builds a mask that's 1.0 inside the crop region and 0.0 everywhere else, padded back to full size. That mask is the gift here: it means you can tell downstream nodes where the crop came from, which is what makes stitch-back and region-paint workflows possible.
There's a frontend layer that makes this feel interactive - you draw the box on a preview, and the numbers update underneath. The aspect_ratio dropdown (Free, 1:1, 4:3, 16:9, 21:9, 3:2, plus an IP-Adapter 224×224 mode) constrains your box while you drag. Pick "IP-Adapter (224x224)" and the crop gets resized to exactly 224×224 with bicubic interpolation, which is what the IP-Adapter CLIP vision encoder expects - that's a genuinely thoughtful touch, because that mismatch is a classic silent failure.
The inputs that matter
- image (optional) - if connected, it overrides the internal file loader. Connect your loaded image for a live workflow.
- image_path - a dropdown of files in ComfyUI's input directory, used when no image is connected.
- crop_x / crop_y / crop_w / crop_h - the normalized box. Usually you let the frontend fill these by dragging.
- active - set to false and the node passes the full image through with a full-size mask. Nice for A/B toggling a crop on and off.
The three outputs - cropped_image, crop_mask, and crop_data (the DICT with pixel and normalized coords plus original dimensions) - cover the three ways you'll want to consume the selection.
Installing it
Part of the Shima pack. ComfyUI Manager → search Shima, or:
cd ComfyUI/custom_nodes
git clone https://github.com/KDB-USJP/shima_wf.git Shima
Restart ComfyUI; first launch auto-installs the pack's deps and companion repos (ComfyUI-Impact-Pack, cg-use-everywhere).
Common issues
- "requires an 'image' input or a selected 'image_path'" - you gave it neither. Either wire an image or pick a file in the dropdown.
- The dropdown is empty. There's nothing in ComfyUI's
input/folder. Drop a file there and refresh. - Crop coordinates feel wrong. Remember they're normalized. If you're hand-typing
crop_w, 1.0 means "the whole image," not 100 pixels. - IP-Adapter results look off. If you're using this for IP-Adapter, use the dedicated 224×224 aspect preset rather than cropping loose and letting the adapter resize later - that exact-resolution path is the reliable one.
For ControlNet-style region work, pair the crop_mask with an inpaint or regional prompting node and the crop_data with anything that wants pixel coordinates. It's one of those nodes that quietly becomes a habit once you've used it once.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image_path | COMBO | 1 options: example.png | |
| crop_x | FLOAT | 0.0000–1 | — |
| crop_y | FLOAT | 0.0000–1 | — |
| crop_w | FLOAT | 1.0000–1 | — |
| crop_h | FLOAT | 1.0000–1 | — |
| aspect_ratio | COMBO | 8 options: Free, Custom, 1:1 Square, 4:3 Standard, 16:9 Widescreen, 21:9 Ultrawide, +2 | |
| orientation | COMBO | landscape | 3 options: landscape, portrait, auto |
| imageopt | IMAGE | If connected, overrides the internal image_path loader. | |
| shima.commonparamsopt | DICT | If connected, frontend can read target width/height for custom ratio. | |
| activeopt | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| crop_mask | MASK | — |
| crop_data | DICT | — |