ImageScaleToTotalPixelsSwitch
ImageScaleToTotalPixelsSwitch
- image
- IMAGE
Same idea as this pack's VAEEncoderSwitch, applied to a different stock node: this is ComfyUI's built-in ImageScaleToTotalPixels with a bypass toggle added on top. The README says it directly - "modified the official ImageScaleToTotalPixels node by adding a switch. When turned off, it will return the input image directly." That's the entire feature. It joins LoadImageWithSwitch, ImageCompositeMaskedWithSwitch, VAEEncoderSwitch, and CheckpointLoaderSimpleWithSwitch as the pack's running theme: take a stock ComfyUI node people wire conditionally all the time, and give it a native on/off input instead of forcing a manual reroute.
The stock node this wraps scales an image to hit a target total pixel count (megapixels) rather than a fixed width/height - useful because it preserves aspect ratio automatically while normalizing images of wildly different source resolutions down to something consistent for a model that expects a specific pixel budget. The switch on top solves a real, specific annoyance: workflows where you sometimes want that normalization (a batch of source images at inconsistent resolutions) and sometimes don't (a single image already at your target size, where rescaling would be pure waste or, worse, unwanted softening from an unnecessary resize pass).
Inputs: image and upscale_method are required, matching the stock node - upscale_method is a COMBO selecting the resampling algorithm (the usual set ComfyUI's scaling nodes expose, like nearest/bilinear/area/bicubic/lanczos). megapixels (default 1, range 0.01–16) is your target total pixel count in millions - 1.0 corresponds to roughly a 1024×1024-equivalent image, scaled proportionally to whatever aspect ratio your input actually has. resolution_steps (default 1, range 1–256) rounds the output dimensions to a multiple of that value - set it to 8 or 16 if whatever comes next needs dimensions divisible by a specific number, which several diffusion and VAE pipelines quietly require to avoid artifacts or outright errors. enabled (default true) is the switch itself - turn it off and the node returns your input image completely untouched, no resizing at all.
Output: a single IMAGE.
Install: search "ComfyUI-utils-nodes" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI afterward. No models, no API keys - this runs entirely on CPU/GPU image math already available in ComfyUI.
What actually trips people up:
resolution_stepsmatters more than it looks like it should. If your downstream sampler or VAE needs dimensions divisible by 8 (a common requirement) and you leaveresolution_stepsat its default of 1, you can end up with dimensions that pass this node fine but cause a shape mismatch or artifact later in the graph. Set it to match whatever constraint your actual pipeline has, not just whatever the default happens to be.- Toggling
enabledoff doesn't just skip the resize - it means whatever fixed pixel budget you were relying on downstream no longer holds. If your workflow assumes a consistent megapixel count past this node (for VRAM budgeting, for a model with a fixed expected resolution), disabling the switch can silently break that assumption on an oversized or undersized input rather than throwing an obvious error. megapixelsis total pixel count, not a per-side dimension - doubling it doesn't double your width and height, it multiplies total pixels by two, which works out to roughly a 1.41× increase per side. If you're trying to hit a specific target resolution rather than just "bigger" or "smaller," compute the megapixel value from your target width × height first rather than guessing.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| upscale_method | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, lanczos | |
| megapixels | FLOAT | 1.000.01–16 | — |
| resolution_steps | INT | 11–256 | — |
| enabled | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |