Nodes/comfyui-OreX/🔳Crop (OreX)
ComfyUI Node

🔳Crop (OreX)

An interactive crop box that remembers your output size

By orex2121·Created about a year ago·Updated 3 days ago· 34
🔳Crop (OreX)
  • image
  • mask
  • image
  • mask
  • width
  • height
crop_left0.0
crop_right0.0
crop_top0.0
crop_bottom0.0
width512
height512
multiplicity16
resolution (MP)0.00
upscale_methodbicubic
aspect_ratioCustom
ratio_lockfalse

Most crop nodes in ComfyUI are blunt instruments: pick pixel offsets, pray you guessed right. Crop (OreX) is the one with a canvas UI - you drag a crop box directly on the preview and the node cuts exactly what you selected. That alone would justify it for anyone doing manual region work, but it goes further: after cropping it can resize the result to a target size or megapixel budget, and it crops your mask alongside the image. It's the node for "I need this exact region, at this exact output size, without it looking mangled."

How it works

The inputs are percentages, not pixels: crop_left, crop_right, crop_top, crop_bottom each take 0–100 (percent of the image dimension), so your crop survives image resolution changes. The bundled JS gives you the interactive drag box; the node converts your percentages to pixel slices, cuts the tensor, and then applies a smart resize:

  • If resolution (MP) is set, it rescales to that megapixel budget while preserving the crop's aspect ratio.
  • Otherwise it uses width / height - but with a guard against the classic "stale widget" bug: if the ratio your widgets suggest is more than 2% off from the crop's actual ratio, it assumes the widgets are leftovers from a previous image and keeps the crop's real dimensions instead of stretching your subject into a pancake.
  • Results are snapped to multiplicity (16 by default) so downstream samplers don't complain.

upscale_method (nearest/bilinear/bicubic/area/lanczos) picks the resampling, and ratio_lock forces an aspect ratio when you drag. Give it a mask and you get the same region cut from the mask, resized to match - so you can crop an image and its mask in lockstep for inpainting or compositing.

Outputs

image (the cropped, resized tensor), mask (the cropped mask - ones-filled if none was supplied), and width / height of the final crop. It's marked as an output node, so it also posts a preview of the crop to the UI.

Install

ComfyUI Manager (search "comfyui-OreX") or:

cd ComfyUI/custom_nodes
git clone https://github.com/orex2121/comfyui-OreX

Restart. No extra dependencies or model files - it's PIL + torch.

Where people get tripped up

The percent-based inputs trip up the first crop: crop_right measures from the right edge inward, so a crop_right of 10 cuts the rightmost 10% off, and same for crop_bottom. If you leave all four at 0 you get the full image resized to width/height, which is a valid (if accidental) resize workflow. And the resolution guard means widgets are sometimes ignored on first run - that's the node protecting you, not misbehaving; set resolution (MP) if you want deterministic control over the output size instead.

Categoryimage/process

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
crop_leftFLOAT0.00–100
crop_rightFLOAT0.00–100
crop_topFLOAT0.00–100
crop_bottomFLOAT0.00–100
widthoptINT5120–16384
heightoptINT5120–16384
multiplicityoptINT161–64
resolution (MP)optFLOAT0.000–100
upscale_methodoptCOMBObicubic5 options: nearest-exact, bilinear, area, bicubic, lanczos
aspect_ratiooptSTRINGCustom
ratio_lockoptBOOLEANfalse
maskoptMASK

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT