LayerUtility: LayerMaskTransform
LayerMaskTransform — move, scale, and rotate a mask independent of its image
- mask
- mask
A geometric transform node that only touches a mask - position, scale, aspect ratio, rotation, mirroring - with no image attached at all. Useful whenever you need to reposition or resize a mask independently of the layer it came from: nudging a subject's cutout mask before compositing it somewhere new, building a simple animation by incrementally shifting a mask frame to frame, or reusing one mask shape at several different scales and positions across a graph without regenerating it each time.
How it works
It takes a mask and applies a standard 2D transform stack to it: translate by (x, y), optionally mirror, scale (uniformly, plus a separate aspect_ratio control to stretch it non-uniformly on top of the base scale), and rotate, all in one pass. Because it's operating on a mask rather than an image, there's no color or content to worry about - just the shape's geometry - which is also why transform_method and anti_aliasing matter more here than they might on an image: a mask edge that isn't resampled carefully turns into visibly jagged or blocky edges once it's used to composite something.
The inputs and outputs that matter
mask- the shape you're transforming.x/y(default 0) - translation offset.mirror(None,horizontal,vertical) - flip the mask before the other transforms apply.scale(default 1, 0.01–100) - uniform resize.aspect_ratio(default 1, 0.01–100) - stretches the mask non-uniformly on top ofscale; leave at 1 for a proportional resize.rotate(default 0, supports fractional degrees) - rotation.transform_method- the resampling algorithm: lanczos, bicubic, hamming, bilinear, box, or nearest. Lanczos or bicubic for smooth results; nearest if you specifically want hard, un-anti-aliased edges (useful for masks feeding pixel-exact operations).anti_aliasing(default 2, 0–16) - extra edge smoothing applied on top of the resampling method.
Output: a single transformed mask.
How to install it
Search ComfyUI Layer Style in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt
Restart; it's under 😺dzNodes → LayerUtility.
Common issues
If a mask edge looks stair-stepped or crunchy after transforming, that's almost always transform_method set to nearest (which is deliberately non-smooth) combined with anti_aliasing left too low - bump both up if you want a clean soft edge, and only reach for nearest when you actually want hard pixel boundaries. The other place people get surprised: aspect_ratio stacks on top of scale rather than replacing it, so setting scale to 1 and aspect_ratio to 2 doesn't just "stretch it 2x," it stretches relative to whatever scale already did - if the result looks bigger or smaller than expected, check both values together rather than assuming one control is broken. And remember this node only ever outputs a mask - if you need the image the mask came from repositioned to match, you'll need a separate image transform in parallel, keeping the same x/y/scale/rotate values on both.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| x | INT | 0-99999–99999 | — |
| y | INT | 0-99999–99999 | — |
| mirror | COMBO | 3 options: None, horizontal, vertical | |
| scale | FLOAT | 1.000.01–100 | — |
| aspect_ratio | FLOAT | 1.000.01–100 | — |
| rotate | FLOAT | 0.00-999999–999999 | — |
| transform_method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest | |
| anti_aliasing | INT | 20–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |