VS Pad + Flatten
The unglamorous first node that keeps your bottle in the same place
- image
- mask
- image
- bottle_mask
Every glass-matte workflow starts with a boring problem: your render is an RGBA cutout with alpha, image models want a flat frame at a fixed aspect ratio, and the moment the framing moves, every downstream node that was calibrated against the old frame is wrong. VS Pad + Flatten is the node that solves that in one step - flatten the alpha onto white or black, then centre-pad to a locked aspect. That's it. No model, no key, no download.
What it's actually for
The pipeline this pack belongs to goes: source render → label pre-lock → send to an image model (the README assumes Nano Banana Pro) → align back → matte. Step three is the one that breaks things. A generative model re-frames, nudges and rescales what you give it, so if the input frame wanders between runs, your label wrap and glass-band calibration - which are stored as fractions of the canvas - drift with it. Padding first pins the canvas so the pipeline has something stable to reason about.
How it works
It reads alpha off your MASK input, flattens the RGB onto a solid background with img * a + bg * (1 - a), then drops that flattened plate onto a centred canvas at the requested aspect. Two details in the source worth knowing:
- If the mask arrives from
LoadImage, it's inverted (1 means transparent), so the node flips it - that's whatmask_is_loadimagecontrols. - If the mask's height and width don't match the image at all, the node assumes fully opaque instead of failing. That guard exists because
LoadImagehands you a 64×64 block of zeros when the file has no alpha channel, and silently blackholing your bottle would be worse than ignoring the mask.
The output mask is the padded canvas mask, un-inverted (1 = bottle). So it lines up with the output image for everything downstream.
The inputs that matter
aspect defaults to 9:16 - the pack's own reference canvas - and also offers 2:3, 3:4, 4:5, 1:1 and source. source is the escape hatch: flatten, no padding, if your model accepts your native ratio. background is white or black; white is the default because the whole later difference-matte step is built on a white plate existing.
mask_is_loadimage is the one field I'd check twice. The author's note is blunt about it: "LoadImage outputs 1 = transparent. Leave on when the mask comes from LoadImage." If your masks come from BiRefNet, the RMBG nodes or anything else in that family, that convention doesn't apply and you flip this off.
Outputs are image and bottle_mask. Both go forward: the image to your generator, the mask wherever you need the silhouette (glass band, crop, drift check).
Install
ComfyUI Manager → search VS Glass Matte (the Comfy Registry listing name), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/andrewclass1/comfyui-vs-glassmatte
# restart ComfyUI
pyproject.toml declares dependencies = [] and there's no requirements.txt on disk - the pack runs on torch and numpy alone, which is a small mercy given how much of the ecosystem's install pain is dependency conflicts. There are no model files either. Nothing to download, nothing to place in a folder.
Where people get burned
The inverted-mask thing is the classic. Get mask_is_loadimage wrong and you'll either flatten the bottle away to a solid white rectangle or paste a black halo around it, and neither error looks like a mask problem at first glance.
The other one is batching. The pack is built for single hero images and processes only the first item of a batch - which is stated plainly in the source, and is fine for its purpose, but don't queue eight bottles through it and wonder where seven went.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| aspect | COMBO | 9:16 | 6 options: 9:16, 2:3, 3:4, 4:5, 1:1, source |
| background | COMBO | white | 2 options: white, black |
| mask_is_loadimage | BOOLEAN | true | LoadImage outputs 1 = transparent. Leave on when the mask comes from LoadImage. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| bottle_mask | MASK | — |