Nodes/comfyui-manga-panel/Manga Panel Composite
ComfyUI Node

Manga Panel Composite

Putting the panel back without wrecking the page

By Tsubasa109·Created 2 months ago·Updated about a month ago· 9
Manga Panel Composite
  • page_image
  • generated_image
  • panel_mask
  • composited_page
  • resized_panel
x0
y0
width512
height512
resize_mode
feather0

Generating a manga panel is the easy half. The hard half is putting it back on the page so it looks like it was always there - aligned to the panel borders, blended at the edges, and with every other pixel of the page untouched. Manga Panel Composite is the node that does that in one shot: you feed it the original page, your freshly generated panel, and the mask from the Selector, and it resizes the generation to fit the panel and composites it back in.

This is the manga-specific version of the rule the inpainting community hammers home constantly: composite after inpainting. Once the community stopped bothering, the discourse thread "PLEASE composite your image after inpainting!" (+356) exists for a reason - uncomposited passes put the whole image through VAE encode/decode cycles and grind it to trash. This node never touches anything outside the panel. The page doesn't pass through a VAE at all, the generated pixels only land inside the selected rectangle, and everything else comes out bit-identical. It's the same structural guarantee crop-and-stitch workflows advertise, just tailored to comics.

How it works

Three things happen in composite_panel, and the source is readable enough to follow along.

First, the generated image is resized to the panel's dimensions, in one of two modes. fill scales so the whole panel is covered and center-crops the overflow - the right call when the model honored the aspect ratio closely, because you get zero gaps. fit scales so the entire generated image fits and leaves the original page showing in any leftover space - the safe mode when the model drifted from the ratio, because you'd rather see the old page than a cropped-off character head.

Second, the alpha channel. The panel mask from the Selector is cropped to the panel and multiplied against where the resized image actually has content. That's what keeps fill and fit both seamless: the mask defines where the panel is, the content alpha defines what of the resized image is there.

Third, the optional feather. Set it above 0 and the alpha edge gets blurred by a pixel-radius kernel, which softens the boundary instead of leaving a hard cut. For hand-drawn manga a hard edge can look wrong - a few pixels of feather makes the generated panel sit in the page instead of on top of it.

Inputs and outputs that matter

The wiring is the whole pack in miniature:

  • page_image - the original page. It must be the same image the Selector saw; the mask and coordinates are meaningless otherwise.
  • generated_image - whatever came out of your KSampler.
  • panel_mask, x, y, width, height - straight from the Selector's outputs.
  • resize_mode - fill or fit, as above.
  • feather - 0 to 128. Start at 0, add 4–8 if the seam bothers you.

Outputs: composited_page, the finished page you save, and resized_panel - the panel as it went in, which is handy for a quick before/after check without peeking at the whole page.

Installing it

Same as the rest of the pack - all three nodes come from one clone:

cd ComfyUI/custom_nodes
git clone https://github.com/Tsubasa109/comfyui_manga_panel.git

Restart ComfyUI, or use ComfyUI Manager and search for comfyui-manga-panel. Zero extra dependencies (the pack's pyproject.toml dependency list is empty - it's torch ops plus a bit of front-end JS), no models to download, no API keys. All local, Apache 2.0.

Gotchas

  • Feed it the same page. The most common failure is wiring a different page into page_image than the one you selected on - the mask dims won't match and it errors, or worse, silently composites onto the wrong page.
  • One page at a time. The node errors on batched images. Batch of 1.
  • Channels must match. Page and generated image need the same channel count, and the mask must be page-sized. If you're seeing dimension errors, check that the Selector's mask actually made it through unchanged.
  • fit leaves gaps, fill loses edges. Neither is a bug - they're the two trade-offs. Pick fill for a clean full-panel look, fit when the generation came out the wrong shape and cropping would amputate something.

The finished workflow reads: Load Image → Selector → Resolution → Empty Latent Image → KSampler → Composite → Save Image. It's a tidy little loop, and the Composite is the node that makes the output look like a real page instead of a floating AI rectangle.

Categoryimage/manga

Inputs (9)

NameTypeDefaultDescription
page_imageIMAGE
generated_imageIMAGE
panel_maskMASK
xINT00–16384
yINT00–16384
widthINT5121–16384
heightINT5121–16384
resize_modeCOMBO2 options: fill, fit
featherINT00–128

Outputs (2)

NameTypeDescription
composited_pageIMAGE
resized_panelIMAGE