Nodes/ComfyUI_LC123_nodes/LC Image-Mask Resize πŸ“
ComfyUI Node

LC Image-Mask Resize πŸ“

Keep your image and mask in the same frame

By lonecatone23Β·Created about a month agoΒ·Updated about 19 hours agoΒ· 10
LC Image-Mask Resize πŸ“
  • image
  • mask
  • image
  • mask
  • width
  • height
β—„match_aspect_ratiofalseβ–Ί
β—„aspect_ratioβ–Ύβ–Ί
β—„custom_width1024β–Ί
β—„custom_height1024β–Ί
β—„upscale_bynoneβ–Ί
β—„multiplier1.00β–Ί
β—„megapixels1.00β–Ί
β—„upscale_methodlanczosβ–Ί
β—„proportioncropβ–Ί
β—„crop_locationcenterβ–Ί
β—„divisible_by8β–Ί

Every second ComfyUI task is "resize this image, and keep its mask in lockstep." Inpaint a face, upscale a region, prep an img2img pair - if the image and mask land at different sizes your detailer silently ignores the mask or composites garbage. That's the friction LC Image-Mask Resize πŸ“ removes: one node, image and mask resized together, plus the width and height out the other side.

It's part of the LC123 "Image & size" family, the same one that gives you the Aspect Ratio Simplifier. The simplifier is the full-fat version - it also carries latent and batch. This one deliberately handles only image + mask, which is exactly the tool you want when you're prepping a mask for a second pass instead of building a whole latent pipeline. Reach for it when you've got a SAM or BiRefNet mask at 512 and the image you want to inpaint is 1344 wide, and you don't want to babysit two resize nodes that might disagree.

How it works

The node picks a target WΓ—H - either one of the presets (Instagram 4:5, 16:9 widescreen, TikTok 9:16, and so on) or your custom_width Γ— custom_height - then walks that size through three stages before resampling.

  • match_aspect_ratio on: instead of forcing the preset, the larger of your width/height settings becomes the long side and the incoming image's ratio is kept. Off: preset or custom size is used as-is.
  • upscale_by then scales that result: none uses the size above, multiplier multiplies it, megapixels sets the total pixel budget at the current ratio (so 1.0 MP of a 4:5 image is a different WΓ—H than 1.0 MP of 16:9).
  • divisible_by floors the final size to a multiple - 8 for SDXL, 16 for Flux / Z-Image, since those models balk at odd dimensions. Set it to 1 to turn that off.

Then the proportion menu decides how the pixels actually land: stretch forces the size, resize fits inside, crop fills and crops (anchor it with crop_location), total_pixels matches a pixel budget. Images resample with your upscale_method (lanczos is the default and a good one for photos); masks go through nearest-neighbor no matter what you pick, so your edges stay hard instead of getting feathered by interpolation.

The inputs that matter

  • aspect_ratio - the preset dropdown, or custom to use the two size boxes below it.
  • match_aspect_ratio + divisible_by - the two you'll actually fiddle with when a model rejects your dimensions.
  • upscale_by / multiplier / megapixels - when you want "make this ~1.5x" or "land at exactly 2MP" rather than a fixed box.

Outputs: image, mask, and width / height as integers - handy for feeding a ShowText-style label or a dynamic latent. Wire only the mask and you'll still get a matching blank image out; wire only the image and the mask output is zeros. Both are harmless, just know what you're looking at.

Install

It ships in the LC123 pack, so you get it either way:

ComfyUI Manager β†’ Install Custom Nodes β†’ search "ComfyUI_LC123_nodes" β†’ Install β†’ Restart

or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/lonecatone23/ComfyUI_LC123_nodes

Then restart ComfyUI - the console prints [LC123] total ... nodes. The pack has no pip dependencies; it runs on ComfyUI's own torch/numpy. One layout gotcha: __init__.py must sit directly in custom_nodes/ComfyUI_LC123_nodes/, not in a nested subfolder - if you unzip a pack zip inside an existing clone, move the inner files up a level (the pack even prints a warning when it spots the nesting).

Where people get burned

  • Wrong divisible_by for your model. 8 is the SDXL default, but Flux and Z-Image want 16. Feed them an 8-multiple latent and you'll get weird resizing or outright errors downstream.
  • match_aspect_ratio does nothing without an input. It needs an image or mask connected to derive the source ratio; feed it nothing and it just uses the settings.
  • Thinking the mask resampled smoothly. It didn't - nearest-neighbor on purpose, so a feathered mask comes out stepped. If you need soft edges, blur the mask after, don't expect the resize to preserve them.

It's a small node, and honestly the pack's whole pitch is "small tools that remove friction." This one is the pair of hands that keeps your mask attached to your image through the resize - boring, until the moment it saves you from a detailer silently doing nothing.

CategoryLC123

Inputs (13)

NameTypeDefaultDescription
match_aspect_ratioBOOLEANfalseOn: keep the incoming image/mask ratio. The larger of the current width/height settings is the long side. Off: use preset or custom WΓ—H as-is.
aspect_ratioCOMBOPreset size, or custom to use custom_width Γ— custom_height.
custom_widthINT102416–16384Target width for custom size. Also the size source (with height) when match_aspect_ratio is on.
custom_heightINT102416–16384Target height for custom size. Also the size source (with width) when match_aspect_ratio is on.
upscale_byCOMBOnonenone = use the size above. multiplier = scale that size. megapixels = set total pixels at the current ratio.
multiplierFLOAT1.000.25–4Scale factor when upscale_by is multiplier. Steps of 0.25, max 4.00.
megapixelsFLOAT1.000.01–8Target megapixels when upscale_by is megapixels. Steps of 0.01, max 8.00.
upscale_methodCOMBOlanczosResampling filter. Lanczos is a good default for photos. Masks use nearest.
proportionCOMBOcropstretch=force size; resize=fit inside; crop=fill+crop; total_pixels=match pixel budget (custom WΓ—H).
crop_locationCOMBOcenterCrop anchor when proportion is crop.
divisible_byINT81–128Final width/height are floored to a multiple of this, then the image/mask is resampled to that size. 16 for Z-Image / Flux; 8 for SDXL. 1 = off.
imageoptIMAGEβ€”
maskoptMASKβ€”

Outputs (4)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”
widthINTβ€”
heightINTβ€”