AgentSkillsCN

comicmaster

只需简短提示,即可生成完整的漫画页面。该工具可自动生成故事分镜,借助ComfyUI生成各幅画面,添加对话气泡,按版式排布页面,并支持导出为PNG、PDF或CBZ格式。当被要求创作漫画、漫画书、连环画、漫画分格或视觉叙事时,可使用此工具。需在Windows上运行ComfyUI。

SKILL.md
--- frontmatter
name: comicmaster
description: Generate complete comic pages from a short prompt. Creates story breakdowns, generates panels with ComfyUI, adds speech bubbles, composes pages with layouts, and exports as PNG/PDF/CBZ. Use when asked to create comics, manga, cartoon strips, comic panels, or visual stories. Requires ComfyUI running on Windows.

ComicMaster

Create complete comics from a short user prompt. Handles story planning, panel generation (ComfyUI), speech bubbles, page layout, and export.

Quick Start

bash
# Full pipeline from story plan
python3 skills/comicmaster/scripts/comic_pipeline.py story_plan.json

# With options
python3 skills/comicmaster/scripts/comic_pipeline.py story_plan.json \
    --preset dreamshaperXL --width 768 --height 768 --formats png,pdf,cbz

# Re-do only bubbles + layout (skip image generation)
python3 skills/comicmaster/scripts/comic_pipeline.py story_plan.json --skip-generate

# Upscale panels after generation
python3 skills/comicmaster/scripts/upscale.py output/panels/ --scale 2.0 --method auto

# Apply color grading
python3 skills/comicmaster/scripts/color_grading.py output/panels/ --grade cyberpunk

Pipeline Flow

code
Story Plan JSON
  → Stage 0.5: Character Reference Generation (IPAdapter)
  → Stage 1: Panel Generation (ComfyUI, batch-optimized)
  → Stage 2: Speech Bubbles (PIL)
  → Stage 3: Page Layout (PIL, dynamic or template)
  → Stage 4: Export (PNG, PDF, CBZ with ComicInfo.xml)

Workflow

Step 1: Story Plan (Agent generates this)

When asked to create a comic, generate a story_plan.json:

json
{
  "title": "The Last Robot",
  "style": "western",
  "preset": "dreamshaperXL",
  "reading_direction": "ltr",
  "characters": [
    {
      "id": "char_01",
      "name": "Kai",
      "visual_description": "young man, 25, short black messy hair, brown eyes, grey hoodie"
    }
  ],
  "panels": [
    {
      "id": "panel_01",
      "sequence": 1,
      "scene": "ruined cityscape at dawn",
      "action": "Kai stands on a rooftop looking over ruins",
      "characters_present": ["char_01"],
      "camera_angle": "low_angle",
      "shot_type": "wide",
      "mood": "melancholic",
      "narrative_weight": "high",
      "character_emotions": "contemplative",
      "character_poses": "standing at edge, hands in pockets",
      "lighting": "dramatic",
      "background_detail": "crumbling skyscrapers, orange dawn sky",
      "dialogue": [
        {"character": "char_01", "text": "Three years since the shutdown...", "type": "speech", "position_hint": "top_right"}
      ],
      "narration": "The world had changed."
    }
  ],
  "pages": []
}

Tip: Leave pages: [] to use dynamic auto-layout based on narrative_weight.

Step 2: Review

After generation, review the output pages (in output/comicmaster/{project}/pages/). Individual panels are in panels/, bubbled versions in panels_bubbled/.

Step 3: Post-Processing (optional)

bash
# Upscale for print (768px → 1536px)
python3 scripts/upscale.py output/panels/ --scale 2.0

# Apply color grading for unified look
python3 scripts/color_grading.py output/panels/ --grade noir

Story Plan Schema

Required Fields

FieldTypeDescription
titlestringComic title
stylestringwestern, manga, cartoon, realistic, noir
characters[]arrayAt least 1 character
characters[].idstringUnique ID (e.g., char_01)
characters[].namestringDisplay name
characters[].visual_descriptionstringDetailed appearance for prompts
panels[]arrayAt least 1 panel
panels[].idstringUnique ID (e.g., panel_01)
panels[].sequenceintOrder number
panels[].scenestringEnvironment description
panels[].actionstringWhat's happening
panels[].characters_presentstring[]Character IDs in this panel

Optional Panel Fields

FieldValuesDefault
camera_angleeye_level, low_angle, high_angle, dutch_angle, birds_eye, worms_eyeeye_level
shot_typeextreme_wide, wide, medium, medium_close, close_up, extreme_closemedium
moodfree text
character_posesfree text
character_emotionshappy, sad, angry, surprised, scared, determined, tired, confused or free text
lightingnatural, dramatic, noir, soft, sunset, moonlight, neon, studio, backlitnatural
background_detailfree text
narrative_weightlow, medium, high, splashmedium
dialogue[]array of dialogue entries[]
narrationstring

Dialogue Entry

json
{"character": "char_01", "text": "Hello!", "type": "speech", "position_hint": "top_left"}

Types: speech, thought, shout, whisper, narration, caption, sfx, explosion, electric, connected, scream Position hints: top_left, top_center, top_right, middle_left, middle_right, bottom_left, bottom_center, bottom_right

SFX entries support "rotation": -15 for angled text.

Bubble Types (11 total)

TypeVisualUse for
speechWhite rounded bubble + tailNormal dialogue
thoughtCloud shape + circle trailInternal thoughts
shoutSpiky starburstLoud dialogue
whisperDashed outline, small textQuiet dialogue
narrationRectangle, no tailNarrator text
captionSmall rectangleLocation/time labels
explosionYellow starburst, red textSFX: BOOM!, CRASH!
electricZigzag edges, cyanRobot/electronic speech
connectedTwo tailsTwo speakers, one bubble
screamJagged red polygonExtreme emotion
sfxRotated outlined text, no bgSound effects overlay

Dynamic Layouts (recommended)

Set narrative_weight per panel and leave pages: [] — sizes calculated automatically:

WeightEffectUse for
lowSmall (~30% row)Reactions, transitions
mediumNormal (equal share)Dialogue, standard
highLarge (~60% row)Action, reveals
splashFull width/pageOpening, climax, finale

Fixed Templates (alternative)

TemplatePanelsDescription
page_2x24Classic 2×2 grid
page_2x362 columns × 3 rows
page_2x482 columns × 4 rows
page_3x263 columns × 2 rows
page_action41 big + 3 small
page_splash31 dominant + 2 side
page_4koma4Vertical strip (manga)

Character Consistency (IPAdapter)

Automatically generates character reference sheets and uses IPAdapter for consistency:

  1. Reference generation: 1024×1024 portrait per character
  2. Upload: Ref uploaded to ComfyUI automatically
  3. Per-panel conditioning: Weight adapts to shot type (0.4 wide → 0.8 close-up)
  4. Auto preset switch: PLUS for body shots, PLUS FACE for close-ups
  5. Multi-character: Chained IPAdapterAdvanced nodes with decreasing weights
CharactersPrimary WeightSecondaryTertiary
1base weight
2base × 1.0base × 0.67
3+base × 1.0base × 0.67base × 0.5

Batch Optimization

For 6+ panels with IPAdapter, the pipeline automatically:

  • Groups panels by IPAdapter requirements (none → single char → multi char)
  • Sorts within groups by character combination
  • Minimizes model switches (tested: 9→5 switches on 10 panels)
  • Shows ETA and progress every 10 panels

Color Grading

Apply unified color palette across all panels:

bash
python3 scripts/color_grading.py panels/ --grade noir
python3 scripts/color_grading.py --list  # show presets
PresetEffect
noirDesaturated, blue-cool, high contrast, vignette
vintageWarm sepia, slight desaturation
vibrantBoosted saturation, punchy
pastelLight, soft, desaturated
cyberpunkCool blue-purple, saturated, vignette
manga_bwFull black & white, high contrast

Panel Upscaling

bash
# Auto-detect best method (ComfyUI model → PIL fallback)
python3 scripts/upscale.py panel.png --scale 2.0 --method auto

# Batch upscale all panels
python3 scripts/upscale.py panels/ --scale 2.0
MethodSpeedQuality
model (4x-UltraSharp)~8s/panelExcellent, detail-preserving
simple (PIL Lanczos)~0.7s/panelGood, fast fallback

Presets (from ComfyUI skill)

PresetStepsSpeedPrompt StyleBest for
dreamshaperXL8~4s/panelNatural languageAll-around default
juggernautXL6~3s/panelNatural languagePhotorealistic
illustriousXL28~15s/panelDanbooru tagsIllustration, Comic, Manga
noobaiXL28~15s/panelDanbooru tagsAnime, Manga (v-prediction)
flux20~15s/panelNatural languageBest prompt adherence

Illustrious XL / NoobAI-XL Notes

These models use Danbooru tag-based prompts instead of natural language descriptions. When you set "preset": "illustriousXL" or "preset": "noobaiXL" in the story plan, the pipeline automatically:

  1. Switches to tag-based prompting — character descriptions are converted to Danbooru tags (e.g., 1boy, short black hair, brown eyes, grey hoodie instead of prose)
  2. Adds quality tagsmasterpiece, best quality, newest, absurdres, highres prefix
  3. Uses optimized negative prompts — model-specific negatives tuned for each architecture
  4. Sets Clip Skip 2 — required for Illustrious models
  5. Handles v-prediction — NoobAI-XL v-pred adds ModelSamplingDiscrete node automatically

When to use which:

Use CaseRecommended
Western comics (general)dreamshaperXL (fast) or illustriousXL (quality)
Manga / anime styleillustriousXL or noobaiXL
PhotorealisticjuggernautXL
Maximum quality (slow)flux
Speed prioritydreamshaperXL (8 steps)

See references/illustrious-xl-guide.md for detailed model comparison, download links, and prompting guide.

Export Formats

FormatDescription
PNGIndividual page images
PDFPrint-ready document
CBZComic reader archive with ComicInfo.xml metadata

Files

ScriptPurpose
comic_pipeline.pyMain orchestrator (lazy-loads panel_generator for --skip-generate)
panel_generator.pyPanel generation via ComfyUI (SDXL + IPAdapter) + sequential composition rules
speech_bubbles.pyPIL-based bubble overlay (11 types) with adaptive font sizing
page_layout.pyPanel → page composition (7 templates + dynamic)
export.pyPDF/CBZ/PNG export
story_planner.pyStory plan validation & enrichment
batch_optimizer.pyPanel ordering for minimal model switches
upscale.py2x/4x upscaling (ComfyUI model or PIL)
color_grading.pyColor grade presets (6 styles)
quality_tracker.pyPIL-based image quality metrics (sharpness, contrast, saturation, entropy, edges, exposure)
utils.pyShared utilities

Workflows (JSON for ComfyUI)

Loadable in ComfyUI UI → Load:

FileDescription
workflows/panel_sdxl.jsonStandard SDXL panel
workflows/panel_illustrious.jsonIllustrious XL panel (Danbooru tags, clip skip 2)
workflows/panel_ipadapter.jsonPanel with single character ref
workflows/panel_ipadapter_multi.jsonPanel with 2+ character refs
workflows/panel_upscale.json4x-UltraSharp upscaling
workflows/character_ref.jsonCharacter reference sheet

Style Guides

See references/style-guides.md for prompt templates per style (Western, Manga, Cartoon, Noir, Realistic).

Camera Angle Guide

PurposeAngleShot
Establishing scenehigh/birds_eyewide/extreme_wide
Character introlow_anglemedium
Dialogueeye_levelmedium/medium_close
Emotion/reactioneye_levelclose_up
Action/impactlow_angle/dutch_anglemedium/wide
Suspensehigh_anglewide

Quality Tracking

Run after each comic generation to measure panel quality:

bash
# Score all panels in a directory
python3 scripts/quality_tracker.py output/panels/ --output scores.json --verbose

# Score single image
python3 scripts/quality_tracker.py panel.png

# With composition analysis (center bias, thirds, flow, harmony, palette)
python3 scripts/quality_tracker.py output/panels/ --composition --verbose

# With panel-sequence analysis (flow continuity, pacing, shot variety)
python3 scripts/quality_tracker.py output/panels/ --composition --sequence --report

# Detailed text report
python3 scripts/quality_tracker.py output/panels/ --composition --sequence --report

Technical Metrics

MetricWhatRangeGood
SharpnessLaplacian variance0-∞>500
ContrastRMS luminance stddev0-12750-80
SaturationMean HSV saturation0-10.25-0.55
Color EntropyHistogram diversity0-16>9
Edge DensityEdge pixel ratio0-10.1-0.3
Exposure BalanceUnder/over exposure0-1>0.6

Composition Metrics (--composition)

MetricWhatRangeGood
Center BiasVisual mass distance from center0-10.2-0.6 (off-center = good, <0.2 = "dead center" flag)
Rule of ThirdsZone variance + hotspot alignment0-1>0.3 (higher = better thirds usage)
Visual FlowDominant gradient direction0°-360°Varies (0° = right, 90° = down). Good when exit matches next panel
Quadrant BalanceVisual weight distribution imbalance0-10.3-0.7 (asymmetric balance is ideal for comics)

Colorimetry Metrics (--composition)

MetricWhatRangeGood
Color TemperatureWarm (red) vs cool (blue) bias-1.0 to 1.0Depends on scene mood. Consistent within a scene is key
Palette SizeNumber of dominant colors (K-Means k=8)1-83-6 (rich but not chaotic)
Color HarmonyHow well colors match harmony patterns0-1>0.5 (complementary, analogous, triadic, split-complementary)

Sequence Metrics (--sequence)

MetricWhatRangeGood
Flow ContinuityDo panels flow toward the next panel?0-1>0.5 (rightward exit for LTR reading)
Temp ConsistencyColor temperature variance across panels0-1>0.7 (consistent within a scene)
Shot VarietyHow different are consecutive panels?0-1>0.3 (varied compositions keep interest)
PacingAlternation between dense/sparse panels0-1>0.3 (rhythmic density changes = good pacing)

Scoring System

Each panel gets:

  • Technical Score (0-100): Weighted composite of sharpness, contrast, saturation, entropy, edges, exposure
  • Composition Score (0-100, with --composition): Weighted composite of center bias, thirds, balance, harmony, palette
  • Overall Score (0-100): 55% technical + 45% composition (or 100% technical without --composition)

Score labels: good (≥65), ok (≥40), poor (<40)

Outputs quality_scores.json with per-panel and aggregate scores. ~50ms/panel basic, ~120ms/panel with composition. Zero external dependencies (PIL + numpy only).

Performance Reference

ScenarioTime
4 panels, no IPAdapter~35s
4 panels + IPAdapter~46s
8 panels + dynamic layout~44s
30 panels + IPAdapter + batch~5-7 min (est.)
Upscale per panel (model)~8s
Color grade per panel~0.2s