[Inference.Core] Generation Resolution From Image
Stop Hardcoding Width and Height
- image
- IMAGE_GEN_WIDTH (INT)
- IMAGE_GEN_HEIGHT (INT)
Here's a habit almost everyone falls into early on: hardcode 512x512 (or 1024x1024, or whatever) into Empty Latent Image and forget about it, until someone drops a portrait photo into your ControlNet workflow and the output comes back squished into a square it was never supposed to fit. This node exists purely to break that habit. It looks at your source image, works out the generation dimensions that actually make sense for it, and hands them back as two numbers you can wire straight into the rest of your graph - so your workflow adapts to whatever gets dropped in, instead of quietly mangling anything that isn't the one resolution you tested against.
There's no detection or model involved - it's a pure utility node, reading the input image's actual dimensions and outputting them in a form your sampler and latent nodes expect (rounded to values diffusion models actually want to work with, rather than whatever odd pixel count the source photo happened to be). It's the kind of node that's boring by design: you wire it in once near the top of your graph and never think about it again.
Inputs and outputs: image is the only input - no optional parameters at all, nothing to tune. Two outputs come back: IMAGE_GEN_WIDTH (INT) and IMAGE_GEN_HEIGHT (INT). Wire those straight into Empty Latent Image's width/height sockets, into your KSampler if it needs them directly, or into the Enchance And Resize Hint Images node elsewhere in this pack if you're also normalizing a separate hint image to match - all three commonly sit downstream of this one in a well-built ControlNet graph.
The real value of this node isn't in any single generation, it's in making a workflow reusable. A workflow with hardcoded dimensions works exactly once, for exactly the image size you built it against. A workflow that starts with this node self-adjusts every time - drop in a landscape photo, get landscape-appropriate dimensions; drop in a portrait, get portrait dimensions. If you're building anything you intend to reuse across different source images (which, if you're doing serious ControlNet work, is most of the time), this is one of those small nodes that pays for itself the first time you forget to manually update a resolution field and it just works anyway.
Installing it: this ships in LykosAI's ComfyUI-Inference-Core-Nodes pack - LykosAI also makes Stability Matrix, the meta-installer a lot of people use to manage multiple local SD UIs, so this pack's install path is more deliberately packaged than a typical solo repo. Search "ComfyUI-Inference-Core-Nodes" in ComfyUI Manager, or manually: cd ComfyUI/custom_nodes && git clone https://github.com/LykosAI/ComfyUI-Inference-Core-Nodes, then run install.py against ComfyUI's own Python environment, or pip install -e .[cuda] / .[cuda12] / .[rocm] / .[directml] / .[cpu] matched to your hardware, or a plain pip install -e . without acceleration extras - this node is pure arithmetic on image dimensions and doesn't touch onnxruntime at all. Restart ComfyUI when done.
Troubleshooting: this is about as low-risk a node as exists in this pack, so there's little to go wrong at runtime beyond the shared install issue affecting the whole pack - ModuleNotFoundError: No module named 'inference_core_nodes' after a git clone means the Python package install step didn't complete, usually from install.py running against the wrong interpreter on a portable ComfyUI build (target python_embeded explicitly there). If the output dimensions look off from what you expected, remember this reflects your source image's proportions rounded to model-friendly values - it's not choosing a "best" generation size for your subject matter, just adapting to the aspect ratio you fed it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE_GEN_WIDTH (INT) | INT | — |
| IMAGE_GEN_HEIGHT (INT) | INT | — |