TdxhImageToSizeAdvanced
Size your SDXL latent without doing the math
- image
- width_INT
- height_INT
- width_FLOAT
- height_FLOAT
- width_STRING
- height_STRING
- width_NUMBER
- height_NUMBER
TdxhImageToSizeAdvanced is the smarter sibling of TdxhImageToSize. Same eight outputs (width/height in INT, FLOAT, STRING, and NUMBER), but instead of just reporting the image's size it computes a target size from a mode you pick, so you can size a latent to match an image while snapping everything to model-friendly values. It's the node in this pack most worth stealing.
The what_to_follow dropdown is the whole show, with seven modes:
- only_width - use your
width, scale the height to keep the image's aspect ratio, rounded to the nearest 8. - only_height - mirror image: fix
height, scale width. - both_width_and_height - use your
widthandheightexactly as given. - width * height - pick a preset pair from the
width_multiply_by_heightdropdown (41 SDXL ratio presets, from0.25:(512, 2048)up to4.0:(2048, 512)). - only_ratio - multiply the image's dimensions by the
ratioslider (0–10, step 0.1), then snap both to multiples of 8. - only_image - just report the image's own size, like the basic node.
- get_SDXL_best_size - snap the image's aspect ratio to the nearest of those same 41 SDXL-native buckets.
The 41 presets are the SDXL training ratio table - the same resolution buckets that show up in A1111's SDXL size suggestions and the official generative-models demo. get_SDXL_best_size does a nearest-ratio search over that table, so you can hand it a portrait phone photo and get back an SDXL-native size like 768×1344 instead of a weird non-multiple. That's the mode that keeps you from generating off-grid resolutions that warp or repeat - the tiling/artifacts class of problems you hit when you push a model far outside its training sizes.
The /8 snapping in the ratio and single-axis modes is the practical detail: latent models like multiples of 8, and the helper rounds rather than floors, so you don't silently lose pixels. Where you'd wire it: take the INT width/height outputs into EmptyLatentImage and you've got a latent that always lands on a valid size for whatever image you loaded.
Installing it
Same pack as the rest: ComfyUI Manager → search tdxh_node_comfyui → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/youyegit/tdxh_node_comfyui
It sits under TDXH → tdxh_image after restart. No models needed. It's a hobbyist pack (GPL-3.0) and the README warns nodes can change between versions - worth a skim of the source before you rely on it in a production-ish pipeline, but for sizing math it's low-risk.
The honest take
get_SDXL_best_size alone is worth the pack. If you build SDXL img2img workflows from arbitrary reference images, this node saves you a calculator and a pile of trial-and-error generations. The other modes are conveniences; that one is a small superpower.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 768128–8192 | — |
| height | INT | 768128–8192 | — |
| width_multiply_by_height | COMBO | 1.0:(1024, 1024) | 41 options: 0.25:(512, 2048), 0.26:(512, 1984), 0.27:(512, 1920), 0.28:(512, 1856), 0.32:(576, 1792), 0.33:(576, 1728), +35 |
| ratio | FLOAT | 1.00–10 | — |
| what_to_follow | COMBO | 7 options: only_width, only_height, both_width_and_height, width * height, only_ratio, only_image, +1 |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| width_INT | INT | — |
| height_INT | INT | — |
| width_FLOAT | FLOAT | — |
| height_FLOAT | FLOAT | — |
| width_STRING | STRING | — |
| height_STRING | STRING | — |
| width_NUMBER | NUMBER | — |
| height_NUMBER | NUMBER | — |