Nodes/ComfyUI_Element_high/EH - Crop Image
ComfyUI Node

EH - Crop Image

The boring crop node that also hands you the receipt

By heyzne·Created 3 months ago·Updated 3 months ago· 0
EH - Crop Image
  • image
  • crop
  • crop_box
x0
y0
width512
height512

The name is not lying. EH - Crop Image takes an image, four integers, and returns a rectangular crop - and if that's all you needed, ComfyUI's built-in ImageCrop does the same thing with fewer moving parts. The reason to bother with this one is the second output: alongside the crop it hands you a crop_box, a four-value rectangle (x, y, x2, y2) that says exactly where that box sat in the original frame. In a crop-and-stitch workflow - crop a region, regenerate just the crop, paste it back - "where did I cut this from" is the piece of information you keep losing. This node keeps it for you.

Where it fits: this is the manual half of Element_high's crop-inpaint-merge pattern, the whole reason the pack exists. The idea is the same one the inpainting crowd settled on: regenerate only a masked region at a resolution the model can actually resolve, and leave every other pixel byte-for-byte untouched. EH_CropImage is for the times you already know the coordinates - from a bbox detector, from reading a pixel position in an editor, from a fixed spot you're processing in a batch. If you'd rather point a mask at the thing and let the crop follow it, that's EH_CropFromMask's job; this node is the "I'll tell you exactly where" version.

How it works: it's a straight PIL crop with bounds-checking. x and y are the top-left corner, width and height the size of the box, and everything clamps to the image edges - ask for a box that runs past the right edge and you get a shorter rectangle, not an error. That clamping is the one thing that will ever surprise you, because it's silent: if you're batch-cropping with computed coordinates that occasionally overshoot, you'll get smaller crops than you asked for and no warning. Worth a sanity check on the first batch.

The inputs that matter:

  • image - the full frame
  • x, y - top-left corner of the crop
  • width, height - box dimensions (defaults to 512×512)

Outputs: crop (the pixels) and crop_box (a BOX value - the (x, y, x2, y2) rectangle). Inside this pack the box is mostly bookkeeping: EH_MergeBack relocates the crop inside the original on its own by template-matching the original_crop you feed it, so you don't have to wire the box anywhere. But any BOX-aware node downstream can consume it, and it's the honest answer to the eternal question, "wait, where did I cut this from again?"

To install, search ComfyUI_Element_high in ComfyUI Manager, or clone it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/heyzne/ComfyUI_Element_high

Restart ComfyUI, and it's there under the "ElementHigh" category. No model files, no extra pip packages - requirements.txt is literally a comment saying the pack only needs ComfyUI defaults (torch, numpy, opencv-python, Pillow), and all four nodes run on CPU-side OpenCV. One heads-up: the README's own install instructions point at a supElement/... repo that no longer exists - the pack is a rewrite of supElement's Element_easy concept but lives under heyzne now, so use the URL above.

Honest verdict: you don't strictly need it, and the pack itself is week-one software with zero community track record. But it's free, dependency-free, and the box output is the difference between "a crop" and "a crop with a receipt." For a utility node, that's a fair deal.

CategoryElementHigh

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
xINT00–99999
yINT00–99999
widthINT5121–99999
heightINT5121–99999

Outputs (2)

NameTypeDescription
cropIMAGE
crop_boxBOX