Nodes/ComfyUI-Apt_Preset/Image_pad_adjust_restore
ComfyUI Node

Image_pad_adjust_restore

Undo Image_pad_adjust and get your original geometry back

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_pad_adjust_restore
  • pad_image
  • stitch
  • restored_image
  • restored_mask
  • original_image
smoothness0

The other half of the Image_pad_adjust pair. Once your padded canvas has been through whatever generation or edit you ran it through, this node strips the padding back off - cropping and repositioning back to the original geometry - using a stitch token that carries all the geometry Image_pad_adjust computed in the first place.

How it works

pad_image is the image after processing - same canvas Image_pad_adjust produced, just with your generation/edit applied on top. stitch (required) is the STITCH4 token from the matching Image_pad_adjust call; it encodes exactly where the original image sat inside the padded canvas, so this node knows precisely what to crop back out. smoothness (default 0) feathers the seam where the restored edges meet, independent of whatever smoothness was set during the pad step itself.

The inputs and outputs that matter

  • pad_image (required) - the processed, still-padded image.
  • stitch (required) - must come from a matching Image_pad_adjust call earlier in the same graph.
  • smoothness (default 0) - feather at the restore boundary.
  • Output: restored_image (back to original dimensions), restored_mask, and original_image - handing back the untouched source, which is a nice touch if you want to compare exactly what changed.

How to install it

Same pack as Image_pad_adjust: via ComfyUI Manager, search ComfyUI-Apt_Preset and install; or clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git into ComfyUI/custom_nodes, run install.bat on Windows or pip install -r ComfyUI-Apt_Preset/requirements.txt on Linux/Mac, and restart. Nothing extra to fetch for this node.

Common issues & troubleshooting

Restored image doesn't line up with the original. This node only works with a stitch token that genuinely came from a matching Image_pad_adjust call - the geometry it encodes is specific to that exact padding operation. Double-check pad_image is really the same canvas the pad step produced and hasn't been resized by anything in between; any resize between pad and restore breaks the coordinate math stitch relies on.

Can't restore an image padded a different way. If you built your padded canvas manually, or with a different node, there's no stitch token to feed this one - it isn't a general "undo any padding" tool, it's specifically the other half of Image_pad_adjust.

Seam visible at the restore boundary. Raise smoothness slightly - it's independent of any feathering you set on the pad side, so a clean pad step can still leave a visible edge on restore if this value is left at 0 and your edit pass changed pixels right up to the boundary.

CategoryApt_Preset/image

Inputs (3)

NameTypeDefaultDescription
pad_imageIMAGE
stitchSTITCH4
smoothnessINT00–500

Outputs (3)

NameTypeDescription
restored_imageIMAGE
restored_maskMASK
original_imageIMAGE