Image Transformer - Resize to Max Pixels
Stop Feeding 12MP Photos to the Sampler
- image
- IMAGE
Diffusion models have a hard native-resolution ceiling - push SDXL or Flux much past 1024 and you get duplicated anatomy, not detail. The community's answer is the same as it's always been: generate at native size, then upscale afterward. But that means anything you feed in - a reference photo for img2img, a ControlNet source, a face to swap - has to come down to a sane size first. That's the whole job of Image Transformer - Resize to Max Pixels: take whatever monster you dragged in and cap it at a pixel budget without touching the aspect ratio.
It's a one-node pack from teamalpha-ai, a tiny utility that does exactly one thing, and nothing else. No models, no API, no dependencies. It's basically a sharper, VAE-aware cousin of ComfyUI's built-in ImageScaleToTotalPixels.
How it works
The math is refreshingly simple. The node looks at your image's height × width, and if that product beats your max_pixels, it scales both dimensions down by sqrt(max_pixels / current_pixels). Aspect ratio survives, and because it rounds down, the result is guaranteed to sit at or under your cap - never over. If the image is already small enough, nothing happens and the original tensor passes straight through.
Resizing uses ComfyUI's own Lanczos resampler (comfy.utils.common_upscale), which is the right call for downscaling - it keeps more fine detail than bilinear and doesn't mush the image the way a lazy bicubic can. There's no cropping anywhere; it's a pure, ratio-preserving resize.
The inputs that matter
There are only three, and two of them are the story:
- max_pixels (INT) - your pixel budget. This is the one you'll actually tune:
1048576for a ~1MP cap,2097152for 2MP, whatever your VRAM and model tolerate. Set it. The default is 1. - vae_scale_factor (FLOAT) - snap the result to multiples of this number, so the output plays nice with the VAE.
8is the standard for SD 1.5, SDXL, and Flux (the value is truncated to an int, so 8.0 and 8 are the same). This applies even when the image was already under the cap - which means you can also use the node purely as a "round these dimensions to multiples of 8" pass by settingmax_pixelshuge. - image - any IMAGE tensor, batches fine.
The single IMAGE output wires straight into whatever's next - VAE encode, sampler, ControlNet, another transform.
Installing it
Via ComfyUI Manager, search ComfyUI-ImageTransformer (it's registry-published, so it should pop up). Or the manual route:
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/teamalpha-ai/comfyui-image-transformer.git
Then restart ComfyUI. That's the entire install - pyproject.toml declares zero Python dependencies and the README confirms it. No model downloads, nothing to cache, nothing that can break your environment. If you find it in a shared workflow and you're security-minded (custom nodes run arbitrary code, and a couple of bad ones slipped through the registry in the past), the whole source is ~60 lines and trivial to read before you run it.
Gotchas
- The default
max_pixelsis 1. Wire this node in without touching the field and a 1024×1024 image becomes a 1×1 gray smudge. This is the #1 way people get burned - it's a shrink-only node with a self-destruct default. Always set a real budget. - It never upscales. If your image is under the cap, it passes through. Don't use this expecting a hires pass.
- It's a young pack - v0.0.1, one node, README says "more utilities planned." For most people the built-in
ImageScaleToTotalPixelsdoes fine; this one earns its keep when you want the cap and VAE-safe rounding in a single step, or as a cheap pre-downscale before a generative upscaler like SeedVR2 - the community's standard trick for soft, oversized sources is to shrink them first so the restorer works on a sharper-relative base.
Expect it in niche workflows more than in your daily graph. But when you need a one-node ceiling on image size, it does exactly what it says.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| max_pixels | INT | 11–999999999 | — |
| vae_scale_factor | FLOAT | 0.000–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |