Nodes/ComfyUI_agilly1989_motorway/ImageScaleToTotalPixels_motorway_edition
ComfyUI Node

ImageScaleToTotalPixels_motorway_edition

Resize to a megapixel target, aspect ratio kept

By agilly1989·Created 2 years ago·Updated about a year ago· 7
ImageScaleToTotalPixels_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_image_keyimage
upscale_method
megapixels1.00
OUTPUT_IMAGE_keyIMAGE

Here's a nicer way to think about resizing: "make this about a million pixels" instead of "make this 1024x1024." That's the whole idea behind ImageScaleToTotalPixels - you set a pixel budget and the node figures out the dimensions, keeping the aspect ratio intact. ImageScaleToTotalPixels_motorway_edition is that node, wrapped for the MOTORWAY 🚌💨 pipe in agilly1989/ComfyUI_agilly1989_motorway.

It reads the image out of the pipe under INPUT_image_key (default "image"), scales it to the target megapixel count, and stores the result back under OUTPUT_IMAGE_key (default "IMAGE"). Only visible output is the Motorway pipe.

Inputs that matter

  • INPUT_image_key (default "image") - pipe key of the source
  • upscale_method - nearest-exact, bilinear, area, bicubic, lanczos
  • megapixels (FLOAT, 0.01 to 16, default 1) - the target total pixel count
  • OUTPUT_IMAGE_key (default "IMAGE") - where the scaled image lands

megapixels is width × height in millions, so 1.0 is roughly a 1024×1024-class image, 2.0 is ~2MP, and so on. The node preserves aspect, so a portrait source and a landscape source both land at the same total count with different dimensions. For "just make it bigger without inventing detail," lanczos is the honest interpolator - fast, predictable, adds no content. If you need exact dimensions instead, use the pack's ImageScale; if you want a clean multiplier, use ImageScaleBy.

How it works

Standard clone mechanics: pop the Motorway, pull the image via the input key, run stock ImageScaleToTotalPixels with upscale_method and megapixels, store the result under the output key, and return a cloned pipe so nothing upstream is mutated.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI, or search "motorway" in ComfyUI Manager. Pure Python, no requirements.txt, no model downloads.

Gotchas

Keys are exact and case-sensitive; a 'MotorwayClass' object has no attribute 'hash_' error means your key string doesn't match anything in the pipe. And the usual case trap - read "image" (lowercase), write "IMAGE" (uppercase) - so chained clones need keys you set to agree. Family status as ever: BETA, with the motorway_edition clones disabled in the 1.1.7 hotfix - if the node's missing from your menu, stock ImageScaleToTotalPixels is the same tool with wires.

Categoryagilly1989 Nodes/Motorway-ed/image/upscaling

Inputs (5)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_image_keySTRINGimage
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
megapixelsFLOAT1.000.01–16
OUTPUT_IMAGE_keySTRINGIMAGE

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨