Restore Autosized Image/Mask
Strip the diffusion padding and land back at your exact source size
- image
- transform
- restored
Ever run a diffusion pass and end up with black bars or repeated edge pixels baked into the result? That's what happens when you pad an image up to a valid resolution and never take the padding back off. Restore Autosized Image/Mask is the cleanup step at the end of a pad-mode autosize workflow, and it exists to make that mistake impossible.
Why you'd want the workflow at all: diffusion models want specific resolutions - SDXL is happiest at 1024, Flux needs dimensions divisible by 64, and so on. But your source image isn't going to cooperate. Image/Mask Autosize's pad mode letterboxes the image up to a divisible canvas, with replicated edge pixels for images and zero padding for masks, so nothing gets cropped away and the aspect ratio survives. Then you sample, then you restore. Outpainting and careful mask-based inpainting both love this, because the masked regions come back bit-identical and the unmasked canvas isn't mangled.
How it works: Restore is deliberately picky. It takes your post-diffusion image plus the same transform record that Image/Mask Autosize produced, then:
- Refuses anything that isn't
padmode - feed it acenterortop_lefttransform and it raises a ValueError telling you it needs pad mode. That's correct behavior: anchored crops are lossy, so there's nothing reversible to restore. - Checks the incoming image is exactly the transform's target dimensions - it won't silently restore something that was already cropped.
- Crops out the pad region using the recorded offsets, then resizes the remainder back to
original_width×original_height.
The inputs are just three: image (IMAGE or MASK), transform (from the Image/Mask Autosize of the same run), and interpolation_mode, which defaults to lanczos. Keep the default - this step actually resizes back to your source size, and lanczos is the least smeary option in the list. The single output is restored, same type you fed in.
Where people get burned: forgetting the whole thing only works with pad mode. If you used an anchored crop on the main node, there's no padding to undo - you're meant to apply the same crop to every aligned asset instead (that's what Apply Autosize Transform is for). And if you skip Restore entirely, you ship an image with the letterbox bars or duplicated edge pixels still in the frame. The dimension check also means you can't feed it a downscaled preview; it wants the actual full padded canvas from the sampler.
Install is shared with the rest of the pack - ComfyUI Manager (search "ComfyUI-ImageAutosize") or:
cd ComfyUI/custom_nodes
git clone https://github.com/SparknightLLC/ComfyUI-ImageAutosize.git
Then restart. No model downloads, no extra Python dependencies beyond ComfyUI's own, though you do need a recent build with V3 MatchType support. The author, SparknightLLC, is the same small developer behind ComfyUI-SpectralVAEDetailer, and this whole pack was adapted from Unprompted's [img2img_autosize] shortcode - a utility node, but a properly engineered one.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMFY_MATCHTYPE_V3 | — | |
| transform | AUTOSIZE_TRANSFORM | — | |
| interpolation_mode | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| restored | COMFY_MATCHTYPE_V3 | — |