Nodes/ComfyUI Warper Nodes/Crop and Restore (Warper)
ComfyUI Node

Crop and Restore (Warper)

Undo your padding without losing pixels

By AIWarper·Created about a year ago·Updated 8 months ago· 14
Crop and Restore (Warper)
  • image
  • preprocess_data
  • image

When you pad an image to a target resolution for a model that demands a fixed canvas, you've committed to a promise: you'll remove that padding on the way out. Crop and Restore (Warper) is the second half of that promise. It takes the padded image plus the metadata its partner produced, crops the padding away, and resizes back to the original dimensions. Run it after sampling or VAE decode and your output is back to the size and framing your input actually had - no letterbox bars, no stretched content, no math by hand.

It's the restoration half of the preprocessing pair in ComfyUI Warper Nodes, the niche pack from workflow author AIWarper. Its counterpart, Preprocess for Target (Warper), does the padding; this node undoes it. That workflow is a core habit for anything that needs fixed-size input but variable-size output - and the pack ships an example for exactly this pattern, built around Flux Kontext's fixed canvas.

How it works

The two inputs are inseparable:

  • image - the processed, padded image that came out of your pipeline.
  • preprocess_data - the PREPROCESS_DATA blob saved by Preprocess for Target. It carries the original size, the crop box, and the scale ratio.

The node crops the image back to the region that held the real content, then resizes it to the recorded original dimensions with Lanczos. Done. The handoff of metadata is the whole trick: without preprocess_data, Crop and Restore has no idea what to crop to, so the two nodes always travel as a matched pair through the graph.

One honest caveat: the node processes the first image of the batch (image[0]). Feed it a batch of frames and you only get frame one restored. For single-image work - the Kontext-style edit use case this pack targets - that's fine. For video, it's a limitation to know about.

Installing it

Same as every Warper node. ComfyUI Manager → search "ComfyUI-WarperNodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/AIWarper/ComfyUI-WarperNodes
# restart ComfyUI

No extra dependencies beyond PIL/numpy, both already in ComfyUI. The README's RAFT model download is for the Flow Visualizer node only.

Common issues

The one way to break this node is to feed it an image that didn't come from its partner node - a padded image with mismatched preprocess_data crops to a garbage region and you get a mangled output. Keep the pair wired together and don't splice in an image from another source. The batch limitation above is real: if your graph processes a batch and only the first frame comes back correct, that's this node's single-frame behavior, not a wiring bug. And since it resizes with Lanczos, output quality is close to the input but not bit-identical - for archival-perfect pipelines, prefer saving before the pad, not restoring after.

CategoryWarper Tools/Preprocessing

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
preprocess_dataPREPROCESS_DATA

Outputs (1)

NameTypeDescription
imageIMAGE