Aspect Ratio and Tile size calculator
Your tile upscaler's math homework, done on the canvas
- image
- aspect_ratio
- width
- height
- upscale_factor
- tile_width
- tile_height
- tile_padding
Aspect Ratio and Tile size calculator answers the question everyone hits the first time they build a tiled upscaling workflow: "what size should my tiles actually be?" You feed it an image plus a target megapixel budget per tile, and it returns the aspect ratio and a sensible tile width and height, so you don't have to do the mental arithmetic mid-graph.
Tiled upscaling is the way to push big images through models on limited VRAM - Ultimate SD Upscale, Tiled Diffusion, or a ControlNet Tile pass all split the image into overlapping chunks, run diffusion per chunk, and stitch it back (the KB's upscaling essay calls this the "arbitrary output size on 6GB" path). The catch is the tile size is the knob that controls both VRAM usage and artifact risk: too big and you're back to OOM, too small and the seams and patchwork artifacts show. This node automates picking the middle ground.
How it works
It reads the source image's dimensions from the IMAGE tensor, computes aspect_ratio = width / height, then solves for tile dimensions. The core math sizes a tile so that, after your upscale factor is applied, each tile lands near your tile_megapixel budget, then adds padding on top:
divisor = floor((c * a) / sqrt(b * 1_000_000 * c / d)) + 1
tile_width = (c * a) / divisor
tile_height = tile_width * d / c
tile_width += p
tile_height += p
It's a closed-form estimate rather than an exhaustive search, which means the tiles come out in the right neighborhood - treat the result as a starting point and sanity-check it against your actual VRAM.
Inputs and outputs
The three you set:
image(IMAGE) - the source you're about to upscale; its dimensions drive everything.tile_megapixel(FLOAT, default1) - target megapixels per tile. 1 MP is a common sweet spot for a single diffusion pass.upscale_factor(FLOAT, default1) - how many × you're scaling, since tile math depends on the final size.tile_padding(INT, default0) - overlap padding in pixels, added to the tile dimensions.
Outputs: aspect_ratio (FLOAT), width/height (INT, the source image's dimensions), upscale_factor and tile_padding (echoes of your inputs), and the useful ones, tile_width/tile_height (INT). Wire those last two into your tiled-upscale node's tile-size inputs.
Installing it
Part of the Skycoder Tools pack:
cd ComfyUI/custom_nodes
git clone https://github.com/skycoder182/comfyui-skycoder-tools.git
# then restart ComfyUI
Or ComfyUI Manager → "Install Custom Nodes" → search "Skycoder Tools" → Install → restart. No models or extra dependencies.
Common issues
The tile dimensions are returned as integers, so fractional pixels get truncated - usually harmless, occasionally off by a pixel from what you intended. And note the padding is added on top of the computed tile size rather than being built into it; if your tiled-upscale node wants padding kept separate from tile size, wire only the tile_width/tile_height outputs and set padding in the upscaler itself. Finally, the aspect_ratio output is a plain width / height float (like 1.78), not a 16:9 style label - if you want the human-readable ratio, that's Image Basic Node's job, not this one's.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| tile_megapixel | FLOAT | 1.000.01–100 | — |
| upscale_factor | FLOAT | 1.000.01–100 | — |
| tile_padding | INT | 00–4096 | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| aspect_ratio | FLOAT | — |
| width | INT | — |
| height | INT | — |
| upscale_factor | FLOAT | — |
| tile_width | INT | — |
| tile_height | INT | — |
| tile_padding | INT | — |