Flux Resolution Prepare
Feed Flux the resolution it actually wants
- image
- image
- ratio
- target_width
- target_height
- area_loss_percent
- pre_scale_factor
Flux is genuinely good at a lot of things, but it's opinionated about resolution. Its training favors specific dimension buckets around a ~1–2 megapixel band, and feeding it a 4:3 photo at an arbitrary pixel size means the sampler is working against the model's grain - soft degradation, mild tiling, anatomy that isn't quite right. The standard advice in the KB is blunt: generate at native-ish resolutions, upscale afterward. FluxResolutionPrepare automates the "make the image Flux-shaped" step so you don't have to memorize the whitelist.
It takes your image and two main knobs. min_megapixels (default 0.95) is the floor for the prepared output; enable_pre_upscale (default on) means that if your source is below that budget, the node upscales it first so the final crop still lands above the floor. Internally it holds a hardcoded list of Flux-legal resolutions - the standard width/height pairs plus their landscape inverses - scores every candidate by how much area you'd lose to cropping and how far the resulting scale would drift from 1.0, and picks the best fit. Then it center-crops to that ratio and resizes to the exact bucket dimensions.
The outputs are what you'd want from a "prepare me for Flux" node: the image itself, the ratio label it chose, target_width and target_height, area_loss_percent (how much of the original you cropped away - 0% means it fit cleanly), and pre_scale_factor (how much it had to upscale to hit min_megapixels). There are also optional crop_width/crop_height/crop_x/crop_y overrides if you want to force the crop region instead of letting it center.
The area_loss_percent output is the one to actually read. If it's high, your source aspect ratio is far from anything Flux likes, and you have a choice: accept the crop loss, or fix the framing upstream. If it's near zero, you found a source that slots straight in - resize only, no wasted pixels.
Install
Manager → search "PortraitUtils", or:
cd ComfyUI/custom_nodes
git clone https://github.com/heyburns/PortraitUtils
Restart. It uses torch interpolation only - no extra downloads, no upscale model required (pre-upscale here is plain bilinear resize, not a super-resolution model).
Common issues
- Image came out blurry -
enable_pre_upscalewith bilinear is a cheap hack to hit the megapixel floor, and cheap upscales look soft. It's meant to be a stopgap: setmin_megapixelslow if your source is small and your real upscaler runs later in the graph. - Crop loss you didn't expect - you're feeding a very non-Flux aspect ratio. Check
area_loss_percent; if it's brutal, that's an upstream framing problem, not this node's. - It resized but didn't change the look - right, it's a pre-processor. The resolution fix shows up in the sampler's behavior, not as a visible edit.
Wire it between your photo loader and the Flux encode/KSampler, and you've offloaded one of the most fiddly constants in Flux workflows to a node that picks it for you every run.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| min_megapixels | FLOAT | 0.950.1–64 | — |
| enable_pre_upscale | BOOLEAN | true | — |
| crop_widthopt | INT | -1 | — |
| crop_heightopt | INT | -1 | — |
| crop_xopt | INT | 0 | — |
| crop_yopt | INT | 0 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| ratio | STRING | — |
| target_width | INT | — |
| target_height | INT | — |
| area_loss_percent | FLOAT | — |
| pre_scale_factor | FLOAT | — |