LayerUtility: Image Mask Scale As V2
Image Mask Scale As V2
- scale_as
- image
- mask
- image
- mask
- original_size
- widht
- height
This is the "resize to match that other thing" node, and it's one of those unglamorous utilities you end up using in nearly every multi-image workflow. Size mismatches break everything downstream - you can't blend, composite, or concat two images at different dimensions - and matching them by hand means copying numbers between nodes. ImageMaskScaleAsV2 takes a reference input and scales your image and/or mask to match it automatically. V2 is the current version, and the thing it adds over the original is a background_color control.
The heart of it is the scale_as input, typed * so it accepts anything with a size - an image, a mask, a latent. The node reads that reference's dimensions and scales your content to fit. Because it follows the reference rather than a hardcoded number, the workflow stays correct when you change resolution upstream; you never go back and edit a resize value.
Settings: fit controls how mismatched aspect ratios resolve - letterbox fits the whole image inside the target and pads the gap, crop fills the frame and trims overflow, fill stretches to exact dimensions (distorting if the ratios differ). background_color is the V2 addition: it's the color of the letterbox padding (default white, #FFFFFF), so if you're fitting into a target and want black bars or a color-matched fill instead of white, this is where you set it - a small thing that saves an extra fill node. method is the resampling filter, lanczos being the sharp default (bilinear/bicubic softer, nearest for hard pixel edges). Both image and mask inputs are optional, so you can scale one or both; running an image and its mask through together keeps them dimensionally locked, which is the usual reason you're here.
Outputs: image, mask, original_size (a BOX holding the pre-scale dimensions in case you want to undo the resize later), and widht and height - "widht" being the pack's own typo - giving the new size as integers for downstream use.
Install is the pack standard: in ComfyUI Manager search "ComfyUI Layer Style" and install, or cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt and restart. No model downloads.
Prefer V2 over the original for the background_color control unless you have no letterbox padding to color. The one setting to be careful with is fit: use letterbox when you must keep the whole image, crop when you can trade edge pixels for a full frame, and steer clear of fill unless deliberate stretching is what you want - a squashed composite is the most obvious sign a resize went sideways. And the recurring LayerStyle warning: if this node never appears after installing the pack, the pack failed to import on a Python dependency conflict (its trademark failure), so check the console, run "Try Fix" in Manager, and reinstall the requirements.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| scale_as | * | — | |
| fit | COMBO | 3 options: letterbox, crop, fill | |
| method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest | |
| background_color | STRING | #FFFFFF | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| original_size | BOX | — |
| widht | INT | — |
| height | INT | — |