Nodes/ComfyUI/Crop Image (Random)
ComfyUI Node Runs on cloud

Crop Image (Random)

Same shape, different middle, every run

By Comfy-Org·Created 4 years ago·Updated about 6 hours ago· 129,874
Crop Image (Random)
  • images
  • images
width512
height512
seed0

Center crop gives you the same middle every time. This is its opposite: same output size, but the crop origin is rolled randomly, so every run takes a different bite out of the image. It's the data-augmentation workhorse that's been sitting inside ComfyUI's newer built-in image/transform nodes, and it's about as close as ComfyUI core gets to a training-tool node.

How it works

Give it width and height (default 512 each) and a seed. It picks a random top-left corner within the valid range - anywhere the crop still fits inside the image - and slices that rectangle out. The math is the same as center crop except the offset comes from a seeded RNG instead of // 2. Same seed, same crop. Change the seed, the crop jumps to a new spot.

That's the entire schema: images, width, height, seed. One output: the cropped images batch. Batch-aware like its sibling, so a stack of frames each gets its own random offset.

Why you'd use it

This is an augmentation node. In training-land, random crops are how you tell a model "the subject is not always dead center" - it forces the model to learn from parts of the image rather than memorizing a fixed framing. Concretely:

  • Dataset prep for LoRA or checkpoint training - random-crop your samples to a uniform size so the training loader gets consistent dimensions and the model learns to generalize across framings.
  • Variety in reference/conditioning images - feeding a model slightly different crops of the same source across runs.
  • Stress-testing composition - if a workflow "should" work regardless of framing, random crops find the case where it doesn't, fast.

If you're a pure inference user - load image, prompt, save - you probably don't need this node at all. Its sibling CenterCropImages is the one for "normalize everything to the same size." Random crop is for when you want the variation.

Where it bites

  • Seed discipline. Seed 0 (the default) is fine for a one-off, but if you run a batch and want different crops for each image, you need to vary the seed - same seed = same offset every time, which makes "random" a lie.
  • No randomness when the crop equals or exceeds the image. If width/height ≥ the image dimensions, the only valid offset is zero, so you get the whole image - every time, seed or not. Randomness only exists when there's slack.
  • It can cut the subject. Unlike center crop, nothing keeps the interesting part in frame. Randomly cropping a portrait can take a bite out of the face. For augmentation that's the point; for a production pipeline it's a hazard. If you want guaranteed composition, use center crop or explicit boxes.
  • Latent rule applies. Non-multiple-of-8 output dims get quietly re-cropped by the VAE encoder later. Keep 512 or a multiple of 8.

Small, seeded, and unapologetically random. Reach for it when you want your data to look less like you arranged it.

Categoryimage/transform

Inputs (4)

NameTypeDefaultDescription
imagesIMAGEImage to process.
widthINT5121–8192Crop width.
heightINT5121–8192Crop height.
seedINT00–18446744073709550000Random seed.

Outputs (1)

NameTypeDescription
imagesIMAGEProcessed images