TS Get Image Megapixels
How big is that image, actually?
- image
- megapixels
The README calls TS Get Image Megapixels "two-line node, but indispensable for routing logic" - and that's the whole review, because it's right. This node takes an IMAGE and returns its area in megapixels as a FLOAT. That's it. But "how big is this image?" is a question you ask constantly when you're building smart workflows, and it's one ComfyUI core doesn't answer directly.
The use case that matters most: conditional routing. The megapixel count is the standard gate for "process at full res or downscale first" - the exact pattern the README quotes ("if image > 4 MP, downscale first"). Different models have different comfort zones, and a megapixel figure is how you express those boundaries. Wire this into a switch node and your graph can auto-adapt to whatever resolution it's fed instead of you hard-coding a size.
How it works
Width × height, divided by a million. 1024 × 1024 → 1.048576. There's no magic - it reads the tensor's dimensions and multiplies them. It's also one of those honest measurements: it measures the tensor size, so if something upstream resized the image, that's what you get - which is exactly what you want for pipeline decisions.
One input (image), one output (megapixels, a FLOAT). Nothing to configure.
Installing it
Part of comfyui-timesaver (ComfyUI Manager → "Timesaver", or the manual clone + pip install -r requirements.txt + restart). No models, no deps beyond the pack.
Where it earns its keep
A few patterns people actually build with it:
- Resolution gating for upscalers - the upscaling doc's first lesson is that "which upscaler" depends on what you're starting from. This node gives you the data to branch: over 4 MP → tile it, under → run it whole.
- Batch-resize decisions - wire it ahead of a resize node and conditionally resize only images above a budget.
- Sanity checks - stick it in a graph once and you'll finally know what resolutions your pipeline actually produces, which is half of debugging "why is this slow/OOM."
Gotchas
The one trap: this measures a single image. Feed it a batch of B frames and it still reports the area of one frame - width × height, not width × height × B. If you're trying to estimate total memory for a batch, multiply the output by the batch size yourself, or check the batch dimension another way. And remember it's a FLOAT output, not an INT - if the downstream node wants an integer, convert or compare against a threshold, because 1.5 > 1 comparisons work fine but a float into an INT socket won't wire without a conversion node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image whose resolution is measured. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| megapixels | FLOAT | Image area (width x height) expressed in megapixels. |