Nodes/BV Node Pack/πŸŒ€ BV Image Dimensions
ComfyUI Node

πŸŒ€ BV Image Dimensions

Make an empty latent match any image's ratio

By BlackVortexAIΒ·Created 9 months agoΒ·Updated a day agoΒ· 7
πŸŒ€ BV Image Dimensions
  • image
  • ratio
  • custom_resolution

The name is a small lie: BV Image Dimensions doesn't change or resize anything. It's a tape measure, not a saw. Feed it any image and it reads the tensor, then hands you two numbers - the image's exact reduced width-to-height ratio and its total pixel budget expressed as one square-area figure. That sounds like the world's most pointless node until you sit it next to its intended partner, because this thing and BV Empty Latent Random Ratio were clearly designed to be plugged into each other.

Here's the workflow it exists to solve. You've got an image - a reference you loaded, a frame you grabbed, a generation you liked - and you want a fresh empty latent at the same aspect ratio and same pixel count, as the start of a new pass. Doing that by hand means gcd-reducing 1920Γ—1080 in your head and then typing the numbers in and hoping they're multiples of 8. This node does the arithmetic for you, and it can do it for any IMAGE in the graph, not just one you typed dims for.

How it works

The mechanism is boring in the best way: pure Python, no GPU, no model, no download. It pulls the height and width off the image's [batch, height, width, channels] shape, reduces W:H with a greatest-common-divisor call (so 1920Γ—1080 comes out as 16:9, not 1920:1080), and returns round(sqrt(width * height)) as the second output - the side length of the square with the same pixel area.

Two deliberate details matter. First, it doesn't round anything to a multiple of 8. That's not an oversight: snapping is the latent node's job, via its alignment widget. Second, the int it returns is the pixel area, not a target width - so 1024Γ—1024 gives 1024, but 1920Γ—1080 gives 1440, and the latent node converts that back into aligned dimensions. Feed it a weird non-standard image and the output stays truthful to that image.

The two outputs and what they wire into

  • image (only input): any IMAGE - a Load Image, a VAE-decoded result, whatever.
  • ratio (STRING): the reduced aspect, e.g. 16:9.
  • custom_resolution (INT): the square-area value.

The pairing is spelled out in the node's own description: connect to BV Empty Latent Random Ratio with its resolution set to Custom and all standard ratios disabled. In practice: convert the latent node's ratios text widget to an input and wire ratio in, wire custom_resolution into custom_resolution, flip the resolution dropdown to Custom, and set alignment where you want the snap (8 is the sensible default). Out comes a latent plus width, height and picked_ratio - straight into your sampler.

Where people get burned

The classic mistake is leaving a standard ratio enabled. The latent node's seed picks randomly among whatever ratios are switched on, so if use_1_1 is still lit, your "reproduce this image's aspect" setup quietly becomes a lottery. The description is explicit: disable all standard ratios when driving it from this node.

Second: don't expect byte-exact dimensions. If your source is 1357Γ—847 and alignment is 8, the latent node rounds the output, so the generated latent is "same aspect, same pixel budget, snapped to the grid" - which is what you actually want for diffusion anyway.

Third, and worth repeating because the name misleads: there's no resized image on the other end. If you need the image and the dims downstream, wire the image to whatever needs it separately.

Install

Part of BV Node Pack (GPL-3.0). Through ComfyUI Manager, search "BV Node Pack"; or:

cd ComfyUI/custom_nodes
git clone https://github.com/BlackVortexAI/bv_nodepack

Then restart ComfyUI and hard-refresh the browser. Note the pack's Registry review is still open (issue #217 on the registry repo), so Manager can lag an older version while that's pending - if you want current, the clone is the reliable route. This node drags in zero extra dependencies and no model files; it's a few lines of math.

CategoryπŸŒ€ BV Node Pack/image

Inputs (1)

NameTypeDefaultDescription
imageIMAGEβ€”

Outputs (2)

NameTypeDescription
ratioSTRINGβ€”
custom_resolutionINTβ€”