Nodes/Sketch2Manga/EmptyLatentImageAdvanced
ComfyUI Node

EmptyLatentImageAdvanced

The empty latent that sizes itself to your image (or your page ratio)

By dmMaze·Created 3 years ago·Updated about a year ago· 48
EmptyLatentImageAdvanced
  • image
  • LATENT
width512
height512
batch_size1
long_side-1
aspect_ratio-1.00

EmptyLatentImageAdvanced is ComfyUI's built-in EmptyLatentImage with two tricks bolted on: a long_side / aspect_ratio mode so you can size a latent by its longest edge without doing the math yourself, and an optional image input that just copies the size and batch from whatever you plug in. It ships in the Sketch2Manga pack because that manga pipeline wants latents that match an input lineart or a fixed page proportion, but it works fine anywhere you'd use the stock node.

How it works

Like the core node, it fills a zero tensor of shape [batch, 4, height // 8, width // 8] - the standard 4-channel, 8×-compressed latent format SD1.5 and SDXL use, ready to feed a KSampler. The extras are just smarter ways to decide what width and height should be.

  • Plug an image in with long_side left at -1, and it silently overrides your width, height, and batch_size from the image's own dimensions and batch count. Useful when your lineart pass already defines the canvas.
  • Set long_side above 0 and it treats that as the longer edge. If you also give an image, it derives the aspect ratio from it; otherwise set aspect_ratio yourself (width/height, e.g. 0.71 for a manga page). The node then computes the short side so the whole latent fits the ratio you asked for.

Inputs that matter

  • width / height (INT, default 512, step 8) - the classic sizing, used when long_side is disabled.
  • long_side (INT, default -1) - set >0 to enable long-edge sizing; -1 means off.
  • aspect_ratio (FLOAT, default -1) - companion to long_side; -1 means off.
  • batch_size (INT, default 1) - how many blank latents you want.
  • image (IMAGE, optional) - the "just match this" shortcut.

Output is a single LATENT, the same as the stock node, so it wires straight into KSampler's latent input.

The gotchas

The // 8 and 4 channels are hardcoded, which means this is a SD1.5/SDXL-era node - don't feed the result into a Flux sampler expecting sensible behavior. And there's a quiet priority order worth knowing: if you set both long_side and aspect_ratio to real values, they override your manual width/height; if you plug in an image with long_side off, it overrides everything. So don't fight it - either let the image decide, or set long_side + aspect_ratio and leave width/height alone.

Install

Same as the rest of the pack - ComfyUI Manager (search "Sketch2Manga"), or cd ComfyUI/custom_nodes && git clone https://github.com/dmMaze/sketch2manga && pip install -r requirements.txt, then restart. Note the requirements file pins old gradio and numpy versions for the pack's separate demo, which can clash with other nodes; if that bites you, this node itself only needs the core image libs. It's a thin convenience wrapper, not a heavy model - no downloads, no weights. If you only need it for matching latents to an existing image, it's genuinely handy; otherwise the stock EmptyLatentImage does the same job.

Categorylatent

Inputs (6)

NameTypeDefaultDescription
widthINT51216–8192
heightINT51216–8192
batch_sizeINT11–4096
long_sideINT-1-1–8192
aspect_ratioFLOAT-1.00
imageoptIMAGE

Outputs (1)

NameTypeDescription
LATENTLATENT