Nodes/ComfyUI_agilly1989_motorway/LatentCrop_motorway_edition
ComfyUI Node

LatentCrop_motorway_edition

Crop before you decode — latent-space trimming via keys

By agilly1989·Created 2 years ago·Updated about a year ago· 7
LatentCrop_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_samples_keysamples
width512
height512
x0
y0
OUTPUT_LATENT_keyLATENT

LatentCrop_motorway_edition wraps core's LatentCrop: it cuts a width × height region out of a latent at position (x, y) - the whole operation happening in latent space, before VAE decode. The motorway edition reads the source latent from a pipe key and writes the cropped result back to a key.

Why crop in latent space at all

Cropping is cropping, but where you do it matters. If you crop in pixel space after decoding, you've decoded the full latent (wasting the decode), and you still have to re-encode if the crop is going to be sampled again. LatentCrop stays in the compressed representation, which is the right call whenever the cropped region is a working region - a tile you're about to sample or img2img, a face you're refining, a segment you're going to composite back later. It pairs naturally with the rest of this pack's latent family: crop a piece, refine it, composite it back.

The four widgets are the entire control surface:

  • width / height (default 512 each, min 64, step 8) - the crop size, in latent-space units. Remember latents are 8x smaller per side than the final image: a 512-wide crop here is a 4096px crop once decoded. The step of 8 exists because latent dimensions must land on multiples of 8.
  • x / y (default 0, step 8) - the top-left corner of the crop.

The key field is INPUT_samples_key (default "samples") for the source latent, and OUTPUT_LATENT_key (default "LATENT") for the result. Only the MOTORWAY 🚌💨 is returned as a socket, so read the cropped latent out with a Motorway AxB ramp when you need it.

Motorway notes

One input key, one output key - about as close to frictionless as this pack gets. Still, the standard gotcha applies: whatever INPUT_samples_key points at must actually be in the pipe, or you'll hit the pack's signature 'MotorwayClass' object has no attribute 'hash_' error. And keep the multiples-of-8 rule in mind; a crop width of 100 isn't a bug in the node, it's a constraint of latent math.

Install and caveats

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI, or install via ComfyUI Manager. No pip deps, no model files - pure tensor slicing.

Standing pack reality check: one-developer beta, mid-refactor, with the current repo HEAD commenting out the _motorway_edition registration - so a fresh clone may not even load this node. The README's "IF THINGS BREAK ITS BECAUSE I BROKE IT" is the author's own framing and worth taking literally. And the usual honest note: LatentCrop is a thin utility even in core, so the wrapper's value is entirely conditional on your workflow already routing latents through keys. If it's not, the stock node is the same slice with less ceremony.

Categoryagilly1989 Nodes/Motorway-ed/latent/transform

Inputs (7)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_samples_keySTRINGsamples
widthINT51264–16384
heightINT51264–16384
xINT00–16384
yINT00–16384
OUTPUT_LATENT_keySTRINGLATENT

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨