Manga Panel Resolution
Stop feeding your model the wrong size
- generation_width
- generation_height
- aspect_ratio
- scale_factor
Manga panels are obnoxious shapes. A wide establishing shot and a tall dialogue panel share one page, and diffusion models punish you for feeding them weird aspect ratios - stretched bodies, doubled anatomy, tiling. Generate at the model's native resolution and every architecture is happy; wander off it and you're gambling. Manga Panel Resolution exists to turn "the panel is 450×800, what do I feed the model?" into a real number that preserves the panel's aspect ratio while landing in the resolution band your checkpoint actually likes.
It's the middle node of the pack's pipeline: the Selector gives it the panel's width and height, it spits out a generation size, you wire that into your latent, generate, and the Composite puts the result back. By itself it's a glorified calculator - but it's the calculator that keeps your tall action panels from coming back with stretched heads.
How it works
The math is straightforward, and it's in the source if you want to check: it takes the panel ratio (width / height), targets target_megapixels pixels, and solves for dimensions - sqrt(target_pixels × ratio) for the width, then back out the height. Then it rounds to the nearest multiple (default 64, which is the standard for SDXL and Flux ladders) and caps the result at max_width / max_height.
The two modes are where it gets slightly clever:
closest_arearounds to a multiple of 64 and only shrinks if the result would exceed your max dimensions. You get the size closest to your target MP, even if it's a bit odd.fit_within_boundsscales the raw dimensions down first so they fit insidemax_width/max_height, then rounds. Prefer this when you're near a VRAM ceiling and a panel is just too elongated.
For a 9:16-ish panel at 1.0 MP with 64-multiple, you get 768×1344 - the README's own example. Note it's rounded, so the real pixel count is 1.03 MP, not 1.0. That's fine; the model doesn't care about exact MP, it cares about being in the band.
Inputs and outputs that matter
You set a handful of things and read one pair of numbers:
panel_width/panel_height- normally straight from the Selector's outputs. Typing them in works too.target_megapixels- default 1.0, range 0.1–16. That's the SDXL/Flux comfort zone. If your checkpoint eats 1.5 MP happily, bump it.multiple- 8, 16, 32 or 64. Keep 64 for SDXL/Flux; drop to 16 if you're generating small panels and want tighter granularity.mode-closest_areaorfit_within_bounds, as above.
The outputs that matter: generation_width and generation_height, wired into Empty Latent Image (or whatever latent node your model wants). aspect_ratio and scale_factor are there too - scale_factor tells you how much bigger the generation is than the panel, which is useful if you ever want to scale a ControlNet strength or denoise to match.
After you queue, a display on the node shows the result as 768 × 1344 / 1.03 MP, so you can sanity-check without counting pixels.
Installing it
Same install as the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Tsubasa109/comfyui_manga_panel.git
Restart, or install via ComfyUI Manager (search comfyui-manga-panel). No extra dependencies, no model files, no API calls - the whole thing is a few torch operations in a pyproject.toml with an empty dependency list.
Gotchas
- It doesn't know your model's trained ratios. SDXL was trained on a specific set - 1024², 1152×896, 1216×832, 1344×768, 1536×640 and their rotations - and this node won't snap to those; it snaps to a multiple of 64 near your target MP. For most 2026 models that's fine, since they accept a megapixel band with soft degradation instead of a hard wall. For an older SDXL checkpoint, nudge
target_megapixelsso the result lands near a trained size. - Exact MP is a lie. It rounds, it caps, it flips to
fit_within_bounds. Treat the number as a target, not a contract. - A panel bigger than
max_width/max_heightcan't grow to target. If your maxes are set to 2048 and the panel is nearly square, you'll get whatever fits. That's expected, not a bug.
The trap people fall into is skipping this node and just multiplying the panel size up. Do that and you'll feed the model something like 900×1600 - off the ladder, halfway between multiples, and on the wrong side of whatever your checkpoint was trained on. Thirty seconds with the Resolution node fixes it.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| panel_width | INT | 5121–16384 | — |
| panel_height | INT | 5121–16384 | — |
| target_megapixels | FLOAT | 1.000.1–16 | — |
| multiple | COMBO | 64 | 4 options: 8, 16, 32, 64 |
| max_width | INT | 204864–16384 | — |
| max_height | INT | 204864–16384 | — |
| mode | COMBO | 2 options: closest_area, fit_within_bounds |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| generation_width | INT | — |
| generation_height | INT | — |
| aspect_ratio | FLOAT | — |
| scale_factor | FLOAT | — |