LayerUtility: Image Mask Scale As
Image Mask Scale As
- scale_as
- image
- mask
- image
- mask
- original_size
- widht
- height
"Make this image the same size as that one." That's the node. Size mismatches are the single most common reason composites and multi-image workflows blow up in ComfyUI - you can't blend, concat, or mask two images that aren't the same dimensions, and matching them by hand means reading off numbers and typing them into a resize node. ImageMaskScaleAs skips that: you give it a reference, and it scales your image and/or mask to match, no numbers required.
The clever part is the scale_as input, typed as * (anything). You can feed it an image, a mask, or a latent - the node reads its dimensions and scales your content to fit. So instead of "resize to 1024×768," you say "resize to match whatever this other thing is," and it stays correct even if the reference size changes upstream. That's the difference between a workflow that breaks when you swap resolutions and one that just follows along.
The settings are short. fit decides how the aspect ratios reconcile: letterbox fits the whole image inside the target and pads the leftover space, crop fills the target and trims the overflow, fill stretches to the exact dimensions (distorting if the aspect ratios differ). Pick crop when you can't afford padding and don't mind losing edges, letterbox when you must keep the whole image, fill only when distortion is fine. method is the resampling filter - lanczos is the sharp default; bilinear/bicubic are softer; nearest preserves hard pixel edges. Both image and mask are optional inputs, so you can scale just an image, just a mask, or both together in lockstep - which is exactly what you want when an image and its mask must stay dimensionally married.
Outputs: image, mask, original_size (a BOX recording the pre-scale dimensions, handy if you need to reverse the operation later), and widht and height (yes, "widht" is the pack's typo) reporting the new size as integers you can route elsewhere.
Install is the pack standard: search "ComfyUI Layer Style" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt and restart. No models.
Note there's a V2 of this node that adds a background_color control for the letterbox padding - if you're letterboxing and care what color the bars are, use V2; this original version pads with a default. Otherwise they do the same job. The main thing to get right is the fit mode: reach for letterbox or crop almost always and avoid fill unless you genuinely want stretching, because a distorted composite is the most obvious tell that something went wrong. And the standing LayerStyle caveat: if the node doesn't show up after install, the pack failed to import on a dependency conflict - check the console, "Try Fix" in Manager, reinstall requirements.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| scale_as | * | — | |
| fit | COMBO | 3 options: letterbox, crop, fill | |
| method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest | |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| original_size | BOX | — |
| widht | INT | — |
| height | INT | — |