Extensions/OdinSam ResolutionEmptyLatent
ComfyUI Extension

OdinSam ResolutionEmptyLatent

Empty latent from aspect ratio and megapixels. Outputs a LATENT sized for SD, Flux, Qwen, or Flux 2.

By odinGitGmail·Created a day ago·Updated a day ago· 0
odinGitGmail/ComfyUI-Odinsam-ResolutionEmptyLatent
Nodes—
On cloudLocal install
Stars0
Updateda day ago
Readme
<div align="center"> <h1>OdinSam ResolutionEmptyLatent</h1> <p> <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a> <a href="pyproject.toml"><img alt="Version" src="https://img.shields.io/badge/version-0.1.0-blue.svg"></a> <a href="https://github.com/comfyanonymous/ComfyUI"><img alt="ComfyUI" src="https://img.shields.io/badge/ComfyUI-Custom%20Node-00b894.svg"></a> <a href="https://www.python.org/"><img alt="Python" src="https://img.shields.io/badge/Python-%3E%3D3.9-3776AB.svg"></a> <a href="https://registry.comfy.org"><img alt="Registry" src="https://img.shields.io/badge/Registry-odinsam--resolution--empty--latent-6c5ce7.svg"></a> </p> <p> <a href="README.md">English</a> · <a href="README.zh-CN.md">中文</a> </p> <p> One ComfyUI node that picks a resolution and builds an empty <code>LATENT</code>. </p> <p> <b>Node:</b> <code>ResolutionEmptyLatent</code> / 分辨率空Latent (OdinSam)<br> <b>Category:</b> <code>OdinSam/ResolutionEmptyLatent</code> · <b>Registry:</b> <code>odinsam-resolution-empty-latent</code> </p> </div>

Features

Seven widgets, in this order.

| # | Widget | Notes | |---|--------|--------| | 1 | Latent type | SD / Flux / Qwen / Flux2 | | 2 | Aspect ratio | 自定义 (custom) is first. 16:9 means width 16, height 9 | | 3 | Width | Editable on every aspect ratio | | 4 | Height | Editable on every aspect ratio | | 5 | Megapixels | 1.0 = 1,000,000 pixels. Default 1.0, range 0.01–16 | | 6 | Multiple | Typed integer. Default 16. Changing it writes the aligned width and height. 1 skips the multiple snap | | 7 | Batch size | Default 1 |

The only output is LATENT.

Sizing

  • The queued latent uses width and height, then snaps to the multiple and the latent stride.
  • Changing the aspect ratio to a preset recomputes width and height from that ratio and the megapixel count, then writes them back.
  • Changing megapixels recomputes the area from the aspect ratio and writes width and height. A preset uses that ratio. Custom uses the current width/height ratio.
  • Changing the multiple does not retarget the area. It aligns the current width and height and writes them back.
  • The multiple only shrinks or crops the remainder, never enlarges. If the short side is shorter than one step, that pass keeps the original sides. 1 skips it.
  • Before writing back, sides are also floored to the latent stride (8 or 16).

Defaults: SD, 自定义, width and height 1024, 1.0 megapixel, multiple 16. Width, height, megapixels, and multiple can be typed immediately.

Latent types

| Type | Channels | Divide pixels by | Models | |------|----------|-------------------|--------| | SD | 4 | 8 | SD, SDXL | | Flux | 16 | 8 | Flux.1 | | Qwen | 16 | 8 | Qwen Image (first generation). Same shape as Flux | | Flux2 | 128 | 16 | Flux 2, Flux 3 |

Z-Image uses the same empty latent shape as Flux / Qwen. Qwen Image 2.1 (64 channels, stride 16) is not in this node.

OdinSamKit

The latent does not depend on KIT. Without it, web/resolution_empty_latent.js still applies Chinese labels and writes width and height when megapixels or the multiple change.

| Item | Requirement | |------|-------------| | Minimum KIT | OdinSamKit ≥ 0.2.0 | | Relationship | Optional (Chinese labels) |

Nothing is hidden. All eight widgets stay on the node.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/odinGitGmail/ComfyUI-Odinsam-ResolutionEmptyLatent.git ResolutionEmptyLatent

Restart ComfyUI. Registry / Manager id: odinsam-resolution-empty-latent.

Menu: 分辨率空Latent (OdinSam) (category OdinSam/ResolutionEmptyLatent).

Minimal graph

this node Latent → [KSampler] latent_image

Match the latent type to the model: SD for SD, Flux for Flux.1, Flux2 for Flux 2.