Extensions/comfyui-panels
ComfyUI Extension

comfyui-panels

Comics/Manga like panel layouts.

By bmad4ever·Created 11 months ago·Updated 2 months ago· 40
bmad4ever/comfyui_panels
Nodes45
On cloudLocal install
CategoryBmad/Panels, sd
Stars40
Updated2 months ago

Nodes (45)

BBox from Ints

The three-second constructor for the pack's bounding boxes

Bmad/Panels
BBoxSnap

The invisible constraint that makes panel edges behave

Bmad/Panels
Bevel Polygon

Round those harsh right-angle panel corners

Bmad/Panels
Build Layout Panels

Where the abstract layout becomes real shapes

Bmad/Panels
Canvas Panel

The boring rectangle every panel workflow secretly starts with

Bmad/Panels
Complementary Cardinals (Grow Panel)

The directions you didn't ask for

Bmad/Panels
Crop Image By BBox

Crop with a bounding box object instead of raw numbers

Bmad/Panels
Crop Mask By BBox

The sibling crop that keeps your mask in sync with your image

Bmad/Panels
Crop Mask Holes

The background-cropping node with the mouthful of a name

Bmad/Panels
Detect Panels In Image

Turn a drawing of a page into real panel polygons

Bmad/Panels
Draw Panels Edges

The node that draws the black lines around your panels

Bmad/Panels
Draw Panels Edges Dashed

Panel borders, but with a sketchier feel

Bmad/Panels
Draw Panels Edges Dotted

The softest border in the pack

Bmad/Panels
Grid Panel Layout Generator

The fastest way to a comic page layout

Bmad/Panels
Grow Panel

Push one edge of a panel out, leave the rest alone

Bmad/Panels
Invert Cardinals (Grow Panel)

Flip N to S and E to W

Bmad/Panels
List Append Panels

Glue two lists of panels together

Bmad/Panels
List Transfer Panels

Splice panel lists with Python slice syntax

Bmad/Panels
Load Panel Layout

The layout that hides inside an image file

Bmad/Panels
Mutate Panel Layout

The layout variation node — turn one comic page into a dozen siblings

Bmad/Panels
Offset Polygon Bounds

Grow or shrink a panel — the node that makes the gutters between panels

sd
Panel to Mask

The node that turns panel shapes into something ComfyUI can actually use

Bmad/Panels
Paste Crops with Masks

The node that stitches your separately-generated panels back into a page

Bmad/Panels
Polygon.bounds

The polygon's bounding box, handed to other nodes as a BBOX

Bmad/Panels
Polygon Origin at Center

The default pivot — panel center, made explicit

Bmad/Panels
Polygon Origin at Centroid

Pivot around where the panel's mass actually is

Bmad/Panels
Polygon Origin at Point

Pivot a panel around any x,y point you type in

Bmad/Panels
Polygon Origin at Vertex

Hinge a panel on one of its own corners

Bmad/Panels
Polygon To Mask

Turn a panel polygon into an actual mask, ready for inpainting

Bmad/Panels
Polygon To Resized Mask

The panel-to-mask node that keeps your crops consistent

Bmad/Panels
Polygon.bounds (unwrapped)

A polygon's bounds as four plain integers, for the other packs

Bmad/Panels
Preview Panel Layout

Preview a page layout before you commit to building panels

Bmad/Panels
Preview Panels

Actually look at your panels before you generate art inside them

Bmad/Panels
Random Panel Layout Generator

Random comic page layouts on demand — the usual place a page starts

Bmad/Panels
Image Relative Crop

Crop a crop, using the original page's coordinates

Bmad/Panels
Rotate Polygon

Spin a panel around any point you choose

Bmad/Panels
Save Panel Layout

Your layouts, saved as PNGs that are secretly the layout itself

Bmad/Panels
Scale Polygon

Stretch or squash a panel — independently on each axis

Bmad/Panels
Skew Polygon

Tilt a panel out of shape for perspective and drama

Bmad/Panels
Slice Panels List

Subset a list of panels with Python slice syntax

Bmad/Panels
Sort Panels

Put Your Comic Panels Back in Reading Order

Bmad/Panels
String Decode Panel Layout

Turn a Line of Layout Text Back Into a Comic Page

Bmad/Panels
String Encode Panel Layout

Freeze a Comic Layout as a Line of Text

Bmad/Panels
Translate Polygon

Nudge a Comic Panel Without Rebuilding the Page

Bmad/Panels
Unpack BBox

Get the Four Numbers Out of a BBOX

Bmad/Panels
Readme

ComfyUI Panels

This packages contains nodes for generating and-or organizing comics-manga like panels, such as the ones below (images have the workflow embedded).

<span> <img src="./workflows/QwenEdit2509 AND Panel with Bleedout Subgraph.png" alt="drawing" style="width:225px;"/> <img src="./workflows/Character Over Panels.png" alt="drawing" style="width:225px;"/> <img src="./workflows/Panels Over Image.png" alt="drawing" style="width:225px;"/> </span>

Panel Layouts

Panel Layouts are abstract hierarchical representations of a series of cuts made on a page to create comic or manga panels.

The process begins with an empty page (a single full-page panel). Initial cuts—whether single or multiple equally spaced ones—divide this page into distinct panels. Subsequent cuts are applied to existing panels and can be nested to achieve arbitrary levels of complexity.

Cuts are defined by:

  • Direction — horizontal or vertical
  • Position — selected from 5 potential relative positions to the panel being cut
  • Angle — a slight deviation from the defined direction for aesthetic purposes
  • Number of cuts — only applicable for one relative position option, where cuts are forced to have equal spacing

Sample layouts are provided in the sample_layouts folder, but you can create and store your own using the Save Panel Layout node.

The image below shows one of the sample layouts:

<img src="./sample_layouts/PanelLayout (1).png" alt="Sample panel layout" style="width:200px;"/>

A Panel Layout does NOT store specific panel properties such as:

  • Corner shape
  • Margins relative to page borders
  • Line thickness or style

However, it can implicitly define relative spacing between panels through the order of cuts, though not with concrete values.

The order of panels (annotated with number stamps) is determined by the cut sequence. By default, this order also defines relative spacing between panels. The first cut(s) create larger margins, suggesting a reading direction parallel to the cut for nested panels, which are visually grouped due to having smaller margins. The panel order aligns with this visual suggestion—to deviate from this pattern, you must modify the panels or their order separately from the layout.

<img src="./images/cuts_and_panels_order.jpg" alt="Cuts and panel order diagram" style="width:450px;"/>

When saving, previewing, or processing a layout, you can choose between left-to-right or right-to-left orientations. These options don't change the underlying data—a layout saved as left-to-right can be used as right-to-left—but help maintain visual coherence with your preferred reading direction.

Panels

Panels are represented as shapely.Polygon objects, defining the concrete shape of each panel on the canvas.

To extract panels from a layout, use the Build Layout Panels node.

These panels can be modified using the following nodes:

  • Rotate Polygon
  • Scale Polygon
  • Translate Polygon
  • Skew Polygon
  • Bevel Polygon
  • Offset Polygon Bounds
<img src="./workflows/Preview Panels.png" alt="Panel preview example" style="width:700px;"/>

Alternatively, panels can be extracted from images using the Detect Panels In Image node. This node uses a basic computer vision algorithm that performs best on blank images with black shapes representing the panels. However, clean and simple panel layouts from comics or manga can also be used effectively as input.

<img src="./workflows/Custom Panel Layout from Mask like Image.png" alt="Panel preview example" style="width:700px;"/> <img src="./workflows/Manga Panel Extration Example A.png" alt="Panel preview example" style="width:700px;"/>

Once a polygon is adjusted as desired, you can convert it into a mask using one of these nodes:

  • Panel to Mask
  • Polygon To Resized Mask (recommended when used with the Paste Crops with Masks node)

To better understand the differences and potential uses of these nodes, refer to the example workflows.

You can use the Draw Panels Edges node to generate an image with the panels' outlines, which you can use to have clear visual separation between the panels and the rest of the page. Additionally, there are nodes available that create panel borders using dashed or dotted lines instead of solid strokes.

<img src="./workflows/Panel Edges Draw Variants.png" alt="Panel preview example" style="width:700px;"/>

As you may have noticed, panels are sometimes referred to as "polygons" in the node names and outputs.
This dual naming, though potentially confusing, is intentional: nodes and outputs using the "polygon" nomenclature are designed for broader compatibility with other packages that may also use shapely.Polygon objects.