APNext H3 Resolution Planner (Crop Only) - by gabbo
Plan your generate-then-upscale resolutions so nothing resamples or pads
- image
- cropped_image
- stage1_width
- stage1_height
- stage2_width
- stage2_height
- upscale_factor
- plan_info
Two-pass workflows - generate at a modest resolution, upscale to a big one - have a quietly awful failure mode. If the two stages don't share compatible dimensions, the upscaler has to resample or pad, and that's where the softness, the seams and the "why is the upscale worse than the base" disappointment come from. This node exists to stop that from ever happening: it plans a stage 1 / stage 2 resolution pair, then center-crops your input image to the exact aspect ratio of that plan so the whole chain stays on clean multiples and nothing ever resamples.
Despite the name, "H3" here is just the pack's lineage - nothing about this is MiniMax-specific. It's a plain resolution planner, ported from gabbo's original node with the algorithm kept intact. If you've ever eyeballed a hires-fix resolution and hoped it was a multiple of 32, this is the automated version of that.
How it works
The planner picks step sizes so both stages land on clean multiples: for a 2x upscale, stage 1 steps in multiples of 32 and stage 2 in multiples of 64 (so stage 2 is exactly double); for 1.5x, stage 1 steps in 64s and stage 2 in 96s. It then computes how much of the input it can keep and center-crops to the target aspect ratio - which is why the input's dimensions are the only thing that drives the plan, and why the node outputs a cropped image rather than letting a later resize node do a sloppy job.
Three resolution_modes cover the common asks:
target_megapixels- hit a target stage-1 size (thestage1_megapixelsslider, default 0.4 MP) while staying as close to the input aspect as possible. The one you'll reach for most.max_stage1_from_input- the largest stage 1 the input can feed natively within your crop budget.max_final_from_input- the largest stage 2 (final) the input can feed natively within the crop budget.
max_crop_percent (default 2%, up to 25%) caps how much input area you're willing to throw away; if nothing fits, it falls back to the least-lossy candidate. Outputs are cropped_image plus stage1_width/stage1_height, stage2_width/stage2_height, upscale_factor, and plan_info - a human-readable summary showing the crop offset, percentage removed and both stages:
mode: target_megapixels @ 2x
input: 1920x1080
crop: 1917x1065 at (1,7) - 1.54% of area removed
aspect: 9:5
stage 1: 864x480 (0.40 MP)
stage 2: 1728x960 (1.58 MP)
Install
Same pack, same routine - ComfyUI Manager (search "comfyui_dagthomas") or:
cd ComfyUI/custom_nodes
git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas
pip install -r requirements.txt
Then restart. There are no model downloads and no API keys - this is pure geometry, so it's the least demanding node in the pack.
Common issues
- Crop feels aggressive - that's the planner being honest about aspect ratio. Raise
max_crop_percentor switch totarget_megapixelsand let it pick a ratio closer to your input. - Upscaler still soft - the planner fixes the resolution chain; it can't fix a weak upscale model. Feed
cropped_imageand the stage dimensions into the upscale properly and check the upscaler itself (the KB's upscaling essay covers the landscape). - No nodes showing after install - this pack historically had a bug that changed the working directory on load and broke ComfyUI's restart button; it's long since fixed, but if you see a
can't open .../main.pyrestart error,git pulland restart again.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| resolution_mode | COMBO | target_megapixels | target_megapixels: hit stage1_megapixels while staying close to the input aspect ratio. max_stage1_from_input: largest stage 1 the input can feed within max_crop_percent. max_final_from_input: largest stage 2 (final) the input can feed within max_crop_percent. |
| stage1_megapixels | FLOAT | 0.400.05–4 | Target stage 1 size in megapixels. Only used by target_megapixels mode. |
| upscale_mode | COMBO | 2x | Stage 1 -> stage 2 factor. 1.5x forces stage 1 onto multiples of 64. |
| max_crop_percent | FLOAT | 2.00–25 | Maximum share of the input area allowed to be cropped away. Only used by the two max_* modes; if nothing fits, the least-lossy candidate is used instead. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| stage1_width | INT | — |
| stage1_height | INT | — |
| stage2_width | INT | — |
| stage2_height | INT | — |
| upscale_factor | FLOAT | — |
| plan_info | STRING | — |