Nodes/D2 Nodes ComfyUI/D2 Size Selector
ComfyUI Node

D2 Size Selector

Preset canvas sizes plus a ready-made empty latent — one node replaces three

By da2el-ai·Created 2 years ago·Updated 5 days ago· 66
D2 Size Selector
  • images
  • width
  • height
  • upscale_factor
  • prescale_factor
  • batch_size
  • empty_latent
preset
width1024
height1024
swap_dimensionsfalse
upscale_factor1.000
prescale_factor1.000
round_methodRound
batch_size1

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 a custom entry.
  • width / height - used when preset is custom. 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, or None for the multiple-of-8 snap.
  • batch_size - how many latents the empty_latent output 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-ComfyUI and 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.

CategoryD2

Inputs (9)

NameTypeDefaultDescription
presetCOMBO7 options: custom, 512 x 512, 512 x 768, 1024 x 1024, 768 x 1024, 832 x 1216, +1
widthINT102464–8192
heightINT102464–8192
swap_dimensionsBOOLEANfalse
upscale_factorFLOAT1.0000.1–16
prescale_factorFLOAT1.0000.1–16
round_methodCOMBORound4 options: Floor, Round, Ceil, None
batch_sizeINT11–64
imagesoptIMAGE

Outputs (6)

NameTypeDescription
widthINT
heightINT
upscale_factorFLOAT
prescale_factorFLOAT
batch_sizeINT
empty_latentLATENT