LayerUtility: ImageScaleRestore
Image Scale Restore (Layer Style)
- image
- mask
- original_size
- image
- mask
- original_size
- width
- height
Image Scale Restore is one node that does two halves of a very common pattern: scale an image down, run some expensive operation on the smaller version, then scale it back up to exactly the original dimensions. The trick is that it remembers the original size and hands it to you as a value, so a second copy of this node can restore the picture pixel-for-pixel instead of you eyeballing a resize. If you've ever downscaled for a slow mask or filter step and then couldn't get back to the precise original size, this is the fix.
Here's the mechanism. Used once, it resizes the image (and an optional mask) by a scale factor or to a target long-edge length, and outputs the original dimensions as a BOX. Used a second time downstream, you feed that BOX back into its original_size input and it scales the processed image back to those exact dimensions. Two instances of the same node bracket your heavy step: shrink, process, restore.
The inputs you'll set:
image- the picture (an optionalmaskrides along and gets scaled identically, which keeps them aligned).scale- a multiplier (0.5 halves it, 2.0 doubles it).scale_by_longest_side- flip this on to ignore the multiplier and instead resize so the longest edge hitslongest_sidepixels. This is the cleaner way to hit a target working resolution regardless of aspect ratio.method- the resampling filter:lanczos(sharpest, the default choice for downscaling),bicubic,bilinear, plushamming,box, andnearest. Lanczos or bicubic for photos; nearest only if you're preserving hard pixel edges.
Outputs: the resized image and mask, the original_size BOX (the important one - save this for the restore step), and width / height as plain ints if you need the numbers elsewhere.
The canonical use: downscale before a VRAM-hungry or slow node - a matting pass, a heavy filter, a detailer - then restore to native size afterward so the rest of your pipeline sees the original resolution. Feeding the BOX through guarantees the round trip lands exactly, no off-by-a-pixel drift.
Worth knowing before you build around it: there's a V2 of this node (Image Scale Restore V2) with a more flexible scale_by dropdown (longest, shortest, width, height, total pixels), and it's the one most people reach for now. This original is perfectly fine and lighter on options; use it if the simple scale-or-longest-side choice covers you, and reach for V2 when you want to target the short edge or a total-pixel budget.
Install is via the ComfyUI Layer Style pack. ComfyUI Manager: search "ComfyUI Layer Style," install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt in the ComfyUI environment and restart. No model download.
The main thing that'll stop it working is the pack-level failure common to everything here: Layer Style is large and dependency-heavy, and its most frequent issue is the whole pack showing "import failed" in the Manager (usually a transformers version conflict), which makes every node in it - this one included - vanish at once. If the node's missing, that's why. Reinstall the pack, use the Manager's "Try Fix," and reinstall the requirements into ComfyUI's real environment if it persists. Node-specifically: keep the mask paired with its image through the round trip so the two stay in register, and reuse the same method on both ends for consistency.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| scale | FLOAT | 1.000.01–100 | — |
| method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest | |
| scale_by_longest_side | BOOLEAN | false | — |
| longest_side | INT | 10244–999999 | — |
| maskopt | MASK | — | |
| original_sizeopt | BOX | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| original_size | BOX | — |
| width | INT | — |
| height | INT | — |