Nodes/IAMCCS-nodes/LTX-2 Crop By Pad (IMAGE batch)
ComfyUI Node

LTX-2 Crop By Pad (IMAGE batch)

Trim frames to LTX-2's grid without doing the math yourself

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
LTX-2 Crop By Pad (IMAGE batch)
  • images
  • images
  • report
pad_x16
pad_y16

LTX-2 is picky about dimensions. Width and height need to land on the right grid, and when you're feeding it an IMAGE batch - say, the tail frames of a previous segment in a long video workflow - nothing guarantees your input already lines up. This node is the "crop" half of that cleanup: it shaves pad_x pixels off the left and right edges and pad_y off the top and bottom of every frame in the batch, all in one pass.

It's a one-trick utility, and that's fine. You pair it with its sibling IAMCCS_LTX2_ImageBatchPadReflect - pad up to make a frame reach the next grid boundary, crop down when a frame overshoots it. Same pack, same category, same reason for existing: keeping the spatial math out of your graph so a wrong number doesn't explode three segments later.

How it works

Feed it an IMAGE tensor (images, shape [B,H,W,C] like every ComfyUI image batch), set pad_x and pad_y, and it slices that many pixels off each side of each frame:

out = images[:, py : h - py, px : w - px, :]

Two details matter. First, it clamps so it never inverts the crop - pad_x is capped at (w - 1) // 2, so you can't accidentally request a negative-width frame. Second, if both values are 0 it's a no-op that passes the batch straight through, which makes it safe to leave wired in even when you're not sure you need it.

Inputs and outputs

Only three inputs, and only one you'll actually touch:

  • images - the IMAGE batch to crop.
  • pad_x, pad_y - pixels removed from left/right and top/bottom (0–512, default 16).

Outputs are images (the cropped batch) and a report STRING that tells you what actually happened, including the effective pad it used after clamping. Wire images into whatever node wanted grid-aligned frames, and drop report into a Text node if you're debugging why something shifted.

Install

This ships inside IAMCCS-nodes, so you get it either from ComfyUI Manager (search "IAMCCS") or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/IAMCCS/IAMCCS-nodes.git

Then restart ComfyUI. No extra dependencies for this node - it's pure tensor slicing on top of ComfyUI core.

Gotchas

The report string is your friend: if you set pad_x: 50 on a 64-wide frame, the node can't honor it and will tell you exactly what it used instead. That's the whole failure mode here. LTX-2 wants width and height divisible by its spatial grid (the pack's own validator uses 16px as the permissive multiple), so crop then check the report before you hit the VAE - a bad dimension surfaces as an ugly encode error, not a friendly message.

Thin utility, no magic. If you've got a frame batch that's slightly too big for LTX-2's grid, this is the fastest way to fix it without dragging an image-math node into the graph.

CategoryIAMCCS/LTX-2

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
pad_xINT160–512
pad_yINT160–512

Outputs (2)

NameTypeDescription
imagesIMAGE
reportSTRING