FunUI Aspect Size:
FunUIAspectSize calculates suitable dimensions for an image or video-generation workflow by combining a reference picture’s proportions with a chosen total pixel budget. It lets you keep a portrait, landscape, or square composition while working at approximately the resolution you want, rather than forcing every picture into the same fixed canvas shape. The calculation first finds dimensions that preserve the picture’s aspect ratio and match the target pixel area, then rounds each dimension to a configurable grid for compatibility with downstream generation tools. This final rounding can slightly change both the proportions and the pixel count. The node is a lightweight sizing utility: it does not resize, crop, encode, or generate image content itself.
FunUI Aspect Size Input Parameters:
image
Required input of type IMAGE. This supplies the reference picture whose width-to-height ratio determines the calculated shape. Only the picture’s dimensions are used; its colors, subject, and visual details do not affect the calculation. For example, a tall portrait produces portrait-oriented dimensions even when the pixel budget is expressed using landscape dimensions. A small reference and a large reference with the same proportions produce the same result when the other settings are unchanged. The node reads height and width from the standard ComfyUI image layout, which is batch, height, width, channels. No default value, numeric range, or selectable options are defined for this input.
width
Required input of type INT, with a default of 768, a minimum of 16, and a maximum of 16384. This is one factor in the total pixel budget, calculated as width × height; it is not a fixed requirement for the resulting horizontal dimension. Increasing it while keeping height unchanged increases the available pixel area, so both calculated dimensions generally increase before rounding. For example, width 768 and height 512 specify a budget of 393,216 pixels, but a portrait reference will produce a narrower, taller result rather than a 768-by-512 landscape canvas. Swapping the width and height settings does not change the result because their product remains the same.
height
Required input of type INT, with a default of 512, a minimum of 16, and a maximum of 16384. This works together with width to define the target total pixel area, rather than directly fixing the resulting vertical dimension. Increasing it while keeping width unchanged gives the calculation more pixels to distribute according to the reference picture’s proportions. Consequently, the reference controls whether the result is tall, wide, or square, regardless of the orientation suggested by these budget settings. The final pixel count may differ from the requested budget because both dimensions are rounded separately and cannot be smaller than the selected grid spacing.
multiple_of
Optional input of type INT, with a default of 32, a minimum of 1, and a maximum of 256. This controls the spacing of the dimension grid: each calculated side is rounded to the nearest multiple of this value, with exact halfway cases rounded upward. Each side is also kept at least as large as this value, preventing a very narrow or very short picture from producing a zero-sized dimension. For example, 32 produces dimensions such as 448 or 896, while 1 allows individual-pixel dimensions and usually keeps the result closer to the ideal proportions and pixel budget. Larger values make dimensions coarser and can introduce greater differences from the target shape or area. The source specifically notes that LTX wants a multiple of 32; choose other values according to the requirements of your downstream workflow.
FunUI Aspect Size Output Parameters:
width
The first output, of type INT, is the calculated horizontal size in pixels. It reflects the reference picture’s proportions at approximately the requested total pixel area, after rounding to the selected multiple. The value is always at least multiple_of for normal valid inputs and is divisible by that setting. You can connect it to a downstream node’s width input when creating a canvas, latent, or clip that should follow the reference picture’s shape. It is not necessarily equal to the width budget setting, and the calculation does not clamp it to that input parameter’s maximum of 16384.
height
The second output, of type INT, is the calculated vertical size in pixels. Use it together with the width output to define the intended canvas or generation dimensions. Like width, it is rounded independently to the selected multiple and kept at least that large, so the final width-to-height ratio is an approximation of the reference ratio rather than an unconditional exact match. For example, a reference picture measuring 1000 by 2000 pixels, with a 768-by-512 budget and multiple_of set to 32, produces width 448 and height 896. This retains the portrait shape while using 401,408 pixels, slightly above the requested 393,216-pixel budget. This output is also not clamped to 16384.
FunUI Aspect Size Usage Tips:
- Choose width and height as a resolution budget, not as a forced canvas shape. A budget of 768 × 512 gives the same result as 512 × 768 when the reference picture and multiple_of are unchanged.
- Keep multiple_of at 32 for an LTX workflow that requires 32-pixel dimension alignment. For other workflows, check the downstream node or model requirements before changing this setting.
- Use multiple_of set to 1 when close agreement with the reference proportions matters and your downstream tools accept arbitrary pixel dimensions. Integer rounding still applies, so an exact ratio is not guaranteed.
- Connect both outputs to the same downstream sizing operation. Connecting only one while leaving the other dimension fixed elsewhere can defeat the intended aspect-ratio calculation.
- Check the final dimensions for unusually wide or tall references. The minimum side length and independent rounding can substantially increase the pixel area relative to the budget for extreme shapes.
- Use a separate resize or image-processing node if you need the reference picture itself to match the calculated dimensions. FunUIAspectSize returns dimensions only and leaves the reference untouched.
- Treat the pixel budget as approximate, not as a strict resource limit. If your workflow has a hard maximum area or maximum side length, validate the resulting dimensions before generation and reduce the budget if needed.
FunUI Aspect Size Common Errors and Solutions:
Required input missing: image, width, or height
- Explanation: These three inputs are required. If one is missing, ComfyUI may reject the workflow during validation before the node runs; the exact message depends on your ComfyUI version.
- Solution: Connect a valid IMAGE source and provide integer values for width and height. The optional multiple_of input can use its default value of 32.
AttributeError: 'NoneType' object has no attribute 'shape'
- Explanation: This can occur if execution receives no actual image instead of a valid ComfyUI IMAGE. The calculation needs the image’s dimensions and cannot obtain them from an empty value.
- Solution: Check that the upstream image loader or processing node successfully produces an image. Reconnect its IMAGE output rather than a mask, latent, or other data type.
IndexError: tuple index out of range
- Explanation: This can occur when an incorrectly shaped object reaches the image input. The node expects a standard ComfyUI image with batch, height, width, and channel dimensions, and directly reads its height and width positions.
- Solution: Use a standard ComfyUI IMAGE output. If a custom node supplies the image, make sure it returns the expected image layout rather than a flattened array or another incompatible structure.
ZeroDivisionError: division by zero
- Explanation: An image with zero height causes division by zero during sizing. A zero-width image can also cause a related message, such as “float division by zero.” These are malformed images rather than normal reference pictures.
- Solution: Reload the original image and inspect upstream cropping or custom processing steps. Ensure the image reaching this node has a positive width and height.
Resulting proportions or pixel count differ from the target
- Explanation: This is usually expected rounding behavior, not an execution error. Both sides are rounded separately, and neither can be smaller than multiple_of. Differences can become pronounced with extreme aspect ratios or a small budget relative to the grid spacing.
- Solution: Reduce multiple_of if your downstream workflow allows it, increase the budget when a coarse grid is required, and inspect the calculated dimensions before generating.
A downstream node rejects the calculated dimensions
- Explanation: FunUIAspectSize does not validate model-specific aspect-ratio limits, maximum pixel areas, or maximum side lengths. A result can be valid for this calculation but unsupported by the next node, especially for extremely wide or tall references.
- Solution: Check the requirements of the node reporting the error. Adjust multiple_of for alignment requirements, reduce the budget for size limits, or prepare a less extreme reference aspect ratio when the model imposes shape limits.
