Nodes/ComfyUI Layer Style/LayerUtility: ImageScaleRestore V2
ComfyUI Node Runs on cloud

LayerUtility: ImageScaleRestore V2

Image Scale Restore V2 (Layer Style)

By chflame163·Created 3 years ago·Updated 9 days ago· 3,118
LayerUtility: ImageScaleRestore V2
  • image
  • mask
  • original_size
  • image
  • mask
  • original_size
  • width
  • height
â—„scale1.00â–º
◄method▾►
◄scale_by▾►
â—„scale_by_length1024â–º

Image Scale Restore V2 is the node you use to shrink an image for an expensive step and then snap it back to the exact original size afterward. It's the upgraded version of the pack's original scale/restore node, and it's the one to reach for - the whole reason it exists is a more flexible way to say what dimension you're scaling by. Downscale for a slow matting or filter pass, do the work on the smaller image, restore to native resolution with no drift. That's the pattern, and V2 makes the "scale by" part far less fiddly.

Mechanically it's a two-part round trip using two copies of the node. The first instance resizes the image (and an optional mask) and, crucially, outputs the original dimensions as a BOX. The second instance takes that BOX back through its original_size input and scales the processed image to those precise dimensions. Because the original size travels as data rather than a number you retype, the restore lands pixel-exact.

What V2 adds over the original is the scale_by control. The inputs you'll set:

  • image - the picture (optional mask scales along with it, staying aligned).
  • scale_by - how to interpret the target: by_scale (a plain multiplier), longest, shortest, width, height, or total_pixel(kilo pixel). This is the upgrade. Targeting the shortest edge or a total pixel budget is genuinely useful - a total-pixel target keeps VRAM predictable regardless of aspect ratio, which the original node couldn't do.
  • scale_by_length - the number that goes with scale_by (e.g. the pixel length for longest/shortest/width/height, or the value for by_scale).
  • method - the resampler: lanczos (sharpest, good default), bicubic, bilinear, hamming, box, nearest. Lanczos/bicubic for photos; nearest only to preserve hard pixel edges.

Outputs match the original: the resized image and mask, the original_size BOX (save this for the restore leg), and width / height as ints.

Real-world use: bracket a heavy node with two of these. Shrink to a total-pixel budget or a fixed long edge before a slow pass - VITMatte edge refinement, a big filter, a detailer - then restore to the original so the downstream pipeline sees full resolution. It's the standard "process cheap, deliver full-size" move, and the total_pixel mode is why people who search for this one keep the tab open.

To install, grab the whole 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 needed.

Troubleshooting is mostly the pack-level one: Layer Style is large and dependency-heavy, and its most common failure is the entire pack showing "import failed" in the Manager (a transformers version clash, usually), which drops every node it contains - this one included - from your menu simultaneously. If it's missing, that's the cause: reinstall the pack, hit "Try Fix," reinstall the requirements into ComfyUI's real Python env if needed. For the node itself, the one habit that saves headaches is keeping the mask paired with its image across the round trip and reusing the same method on both legs so the shrink and restore stay consistent.

Category😺dzNodes/LayerUtility

Inputs (7)

NameTypeDefaultDescription
imageIMAGE—
scaleFLOAT1.000.01–100—
methodCOMBO6 options: lanczos, bicubic, hamming, bilinear, box, nearest
scale_byCOMBO6 options: by_scale, longest, shortest, width, height, total_pixel(kilo pixel)
scale_by_lengthINT10244–99999999—
maskoptMASK—
original_sizeoptBOX—

Outputs (5)

NameTypeDescription
imageIMAGE—
maskMASK—
original_sizeBOX—
widthINT—
heightINT—