D2 Size Selector
Preset canvas sizes plus a ready-made empty latent — one node replaces three
- images
- width
- height
- upscale_factor
- prescale_factor
- batch_size
- empty_latent
D2 Size Selector is the node that replaces the "Empty Latent Image" + a handful of manual number boxes you keep re-entering. Pick a resolution from a dropdown (or read it off a connected image), optionally scale it, and it hands you both the dimensions and a ready-made empty latent at the right size and batch. In the D2 pack it's the natural size source for D2 KSampler, but the width/height/empty_latent outputs are plain enough to feed any normal workflow.
The inputs that matter
preset- resolution presets from the pack's config (config/sizeselector_config.yaml, editable). The dropdown is prepopulated with common SDXL/portrait sizes and acustomentry.width/height- used whenpresetiscustom. Defaults 1024 × 1024.images- optional IMAGE input. Connect one and the node takes the size from the image instead of the numbers. This is the img2img workflow saver: resize-to-source becomes automatic.swap_dimensions- flips width and height. Handy for portrait/landscape toggling without editing presets.prescale_factor- the output width/height are rescaled by this factor and snapped to a multiple of 8 (VAE-friendly).upscale_factor- passed through untouched; it doesn't resize anything in this node, it just carries the number for a downstream resize node.round_method-Round,Floor,Ceil, orNonefor the multiple-of-8 snap.batch_size- how many latents theempty_latentoutput holds (1–64).
Outputs: width, height, upscale_factor, prescale_factor, batch_size (passthroughs), and empty_latent (a LATENT you can feed straight into a KSampler). It genuinely replaces three or four nodes in a typical graph.
How it works
The priority order is worth knowing: if images is connected, its size wins (that's the "use image size" mode, with preset set to custom); otherwise the preset dimensions are used. swap_dimensions applies after that, then prescale_factor rescales. The latent is created as [batch_size, 4, height // 8, width // 8] - which is exactly why dimensions get snapped to multiples of 8 first.
The one subtle bit: if you connect an image and a preset at the same time, the preset overrides the image size. If you want image-derived size, keep preset on custom.
Installing
Part of the D2-nodes-ComfyUI pack - install the pack, not the node.
- ComfyUI Manager → search "D2-nodes-ComfyUI" → Install → restart.
- Or
cd ComfyUI/custom_nodes && git clone https://github.com/da2el-ai/D2-nodes-ComfyUIand restart.
Dependencies: piexif, charset-normalizer - no model downloads. Pack gotchas: v32.0.0+ requires the ComfyUI V3 schema (older ComfyUI → pre-32.0.0 release), and if you have the old standalone ComfyUI-d2-size-selector pack, delete it - it merged into this one.
Notes
The presets live in a YAML config file inside the pack install - if your favorite size isn't in the dropdown, add it there and restart rather than fighting with custom every time. And if you're using this in a hi-res fix chain, remember upscale_factor is just a number that travels with the node; the actual rescaling happens in D2 Image Resize or an upscale model downstream. This node's job is to be the single source of truth for canvas size.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| preset | COMBO | 7 options: custom, 512 x 512, 512 x 768, 1024 x 1024, 768 x 1024, 832 x 1216, +1 | |
| width | INT | 102464–8192 | — |
| height | INT | 102464–8192 | — |
| swap_dimensions | BOOLEAN | false | — |
| upscale_factor | FLOAT | 1.0000.1–16 | — |
| prescale_factor | FLOAT | 1.0000.1–16 | — |
| round_method | COMBO | Round | 4 options: Floor, Round, Ceil, None |
| batch_size | INT | 11–64 | — |
| imagesopt | IMAGE | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| upscale_factor | FLOAT | — |
| prescale_factor | FLOAT | — |
| batch_size | INT | — |
| empty_latent | LATENT | — |