Nodes/Allor Plugin/ImageTransformCropRelative
ComfyUI Node

ImageTransformCropRelative

Crop by fractions, not pixels, and stop doing math

By Nourepide·Created 3 years ago·Updated 2 years ago· 295
ImageTransformCropRelative
  • images
  • IMAGE
start_x0.25
start_y0.25
end_x0.75
end_y0.75

"Cut off the outer 25% on every side" is a sentence, not an arithmetic problem - but with pixel-based cropping it becomes one every time the image size changes. Allor's ImageTransformCropRelative lets you say it directly: all four crop boundaries are fractions of the image's own width and height, from 0 (left/top edge) to 1 (right/bottom edge). The default values crop out the middle 50% of the image. No resizing, no re-deriving coordinates when you swap in a different-size input.

It's part of the Allor Plugin (Nourepide/ComfyUI-Allor), the pack that keeps RGBA and batches intact through its transform family. Relative is the friendly sibling of ImageTransformCropAbsolute - same crop operation, coordinates expressed as proportions so they survive any input resolution.

How it works

The node reads the first image's dimensions, multiplies the four fractional inputs by width (for start_x/end_x) and height (for start_y/end_y), then hands the resulting pixel box to the pack's Absolute crop node. So the mechanism is PIL crop under the hood, but the input contract is normalized:

  • start_x (FLOAT, default 0.25) - left edge as a fraction of width.
  • start_y (FLOAT, default 0.25) - top edge as a fraction of height.
  • end_x (FLOAT, default 0.75) - right edge as a fraction of width.
  • end_y (FLOAT, default 0.75) - bottom edge as a fraction of height.

The defaults keep the central half: 0.75 - 0.25 = 0.5 of each axis. A full-image pass is 0/0/1/1; a center-symmetry crop is the classic 0.25/0.25/0.75/0.75. Because everything is proportional, the same settings give you the same composition regardless of whether the input is 512×512 or 1344×768 - which is exactly why this node belongs in reusable workflows.

Output is an IMAGE at the cropped size, alpha preserved, batch-friendly: every frame gets the same relative region.

Inputs and outputs

  • images (IMAGE) - single frame or batch.
  • start_x, start_y (FLOAT, default 0.25) - top-left corner as fractions.
  • end_x, end_y (FLOAT, default 0.75) - bottom-right corner as fractions.

Output: IMAGE, cropped.

Installing it

Same pack, same routine: ComfyUI Manager → "Allor Plugin" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor

No models needed for the transform family.

Where people get burned

Two classic mistakes. First, values outside 0–1 are allowed by the schema but nonsense - an end_x of 1.5 crops past the image edge (harmlessly clamped, but you'll get a sliver you didn't plan). Second, mixing up start and end: start_x bigger than end_x produces a degenerate box, and since the defaults are a nice-looking center crop, it's easy to nudge one value and not notice you've inverted the box. And remember the caveat that applies to the whole pack's crop nodes: relative coordinates are resolved against the first frame, so a mixed-size batch will misalign - keep batches uniform.

Categoryimage/transform

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
start_xFLOAT0.25
start_yFLOAT0.25
end_xFLOAT0.75
end_yFLOAT0.75

Outputs (1)

NameTypeDescription
IMAGEIMAGE