Nodes/ComfyUI LC123 Nodes/πŸ“ LC Aspect Ratio Simplifier
ComfyUI Node

πŸ“ LC Aspect Ratio Simplifier

One node to size your image, mask, and latent β€” Aspect Ratio Simplifier

By lonecatone23Β·Created 2 months agoΒ·Updated 3 days agoΒ· 18
πŸ“ LC Aspect Ratio Simplifier
  • image
  • mask
  • image
  • mask
  • width
  • height
  • latent
  • batch
  • resolution
β—„max_resolution2048β–Ί
β—„resolution_sourcefalseβ–Ί
β—„aspect_ratioβ–Ύβ–Ί
β—„custom_width1024β–Ί
β—„custom_height1024β–Ί
β—„swap_dimensionsβ–Ύβ–Ί
β—„upscale_methodlanczosβ–Ί
β—„proportioncropβ–Ί
β—„crop_locationcenterβ–Ί
β—„pad_color0, 0, 0β–Ί
β—„divisible_by8β–Ί
β—„batch_size1β–Ί

Every ComfyUI graph eventually needs to make an image and a mask agree on a size. Resize one, crop the other, keep both divisible by 8 so the latent doesn't complain - it's a string of small nodes that eats your canvas for breakfast. The Aspect Ratio Simplifier is LC123's answer: one node that takes an image and/or mask and outputs the resized pair plus the empty latent, the width, the height, the batch count, and the resolution. It's the kind of node you install once and wonder how you lived without.

The trick is resolution_source. Leave it off and the node derives the target size from whatever image or mask you feed it - it just normalizes both to match, which is exactly what you want after an img2img pass where your mask came from a different resolution than your image. Flip it on and you get to choose the size directly: a preset (Instagram Portrait (4:5), Widescreen (16:9), TikTok (9:16), even the CivitAI Cover (4:1) one people always want) or a custom_width Γ— custom_height.

Then proportion decides the philosophy, and it's worth reading the tooltips because they're the whole node in five words:

  • stretch - force to size, distortion welcome
  • resize - fit inside the target box, no cropping
  • crop - fill and crop to the target (default, and the one for latent work)
  • pad - fit and letterbox, with pad_color for the bars
  • total_pixels - match a pixel budget instead of exact dimensions

crop_location picks the crop anchor when you're in crop mode (center is the default, but top/left matter when you're cropping faces out of headroom), and divisible_by rounds both sides to a multiple of 8 by default - the standard for latents so you don't hit the "latent has wrong size" class of errors. max_resolution clamps the longer side to keep you out of VRAM territory; 0 means no clamp. upscale_method defaults to lanczos, which is the right call for photos; the list also has nearest-exact for pixel art and nvidia_rtx_vsr if you have an RTX card and want the hardware scaler.

Outputs are the gift that keeps on giving: image, mask, width, height, a ready-made empty latent at the same size (batch from batch_size), and batch plus resolution for anything downstream that wants to log or label. Wire the latent straight into a KSampler and the numbers into a text node, and you've removed about four nodes from a typical workflow.

Where people trip: forgetting resolution_source is on. If you flip it on expecting presets and the node seems to ignore you, that's usually it - it's sized from the image while the toggle is off. Also keep divisible_by in mind for SD models; some checkpoints get grumpy at sizes that aren't multiples of 8 even though the node technically accepts anything β‰₯1.

Same install as the rest of the pack - ComfyUI Manager, search "LC123", or:

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

Restart, then drop this where your image sizing happens. No extra dependencies; it's all ComfyUI's own torch/ComfyUI utils under the hood.

CategoryLC123/image

Inputs (14)

NameTypeDefaultDescription
max_resolutionINT20480–16384Clamp longer side. 0 = no clamp.
resolution_sourceBOOLEANfalseOff: size from image/mask. On: use preset or custom width x height.
aspect_ratioCOMBOPreset ratio when using custom/preset source.
custom_widthINT102416–16384Target width for custom size.
custom_heightINT102416–16384Target height for custom size.
swap_dimensionsCOMBOSwap width and height after size is chosen.
upscale_methodCOMBOlanczosResampling filter. Lanczos is a good default for photos.
proportionCOMBOcropstretch=force size; resize=fit inside; crop=fill+crop; pad=fit+letterbox; total_pixels=match pixel budget.
crop_locationCOMBOcenterCrop anchor when proportion is crop.
pad_colorSTRING0, 0, 0RGB for pad mode. 0-255 or 0-1.
divisible_byINT81–128Round width/height to a multiple of this (8 is typical for latents).
batch_sizeINT11–4096Empty latent batch. Image/mask batch is preserved from input.
imageoptIMAGEβ€”
maskoptMASKβ€”

Outputs (7)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”
widthINTβ€”
heightINTβ€”
latentLATENTβ€”
batchINTβ€”
resolutionINTβ€”