---
name: comic-maker
description: "สร้างคอมมิค/การ์ตูน/มังงะ/มังฮวา/เว็บตูน ทุกแนว ใช้เมื่อ: user พูดถึง 'สร้างการ์ตูน' หรือ 'make a comic/manga/webtoon' หรือ 'one-shot/การ์ตูนสั้น' หรือเนื้อเรื่องที่อยากเห็นเป็นรูปเล่ม"
license: MIT
metadata:
  version: 3.0.0
  tags: [comic, manga, manhwa, webtoon, image-generation, export]
---

# Comic Maker

สร้างสรรค์คอมมิคทุกแนว — action, romance, comedy, horror, fantasy, slice-of-life, drama
ไม่ใช่แค่การ์ตูนความรู้ แต่เป็นการ์ตูนเพื่อความบันเทิงที่มีเนื้อเรื่อง ตัวละคร อารมณ์ร่วม

## Architecture

```
comic_maker/
├── models.py          # Panel, Page, Comic + Enums (single source of truth)
├── builder.py         # ComicBuilder — fluent API with step validation
├── engine.py          # ComicEngine — event-driven plugin system
├── events.py          # EventBus + ComicEvent enum
├── plugins.py         # Plugin base classes + registry
├── plugins_image.py   # ImageClassifier, ImagePrompt, MotionEnhancer
├── export.py          # Real-world output (JPG/PNG/CBZ/thumbnails)
├── workflow.py        # Step logic (used by builder)
├── validation.py      # Step validation helpers
├── exceptions.py      # Custom exceptions
scripts/
├── svg_comic.py       # SVG page renderer (manga/manhwa/western)
├── anti_slop.py       # Text quality checker
```

## Quick Start (3 lines)

```python
from comic_maker import ComicPipeline
pipe = ComicPipeline()
comic = pipe.storyboard("A samurai seeks revenge...")
paths = pipe.render(comic, "output/")
```

## Builder (step control)

```python
from comic_maker import ComicBuilder, Genre, ArtStyle, Tone

result = (
    ComicBuilder("A cyberpunk detective mystery")
    .genre(Genre.SEINEN)
    .art_style(ArtStyle.SEMI_REALISTIC)
    .tone(Tone.MYSTERIOUS)
    .analyze()
    .confirm(title="Neon Shadows")
    .storyboard(pages=3)
    .review_storyboard(approved=True)
    .prompts()
    .review_prompts(approved=True)
    .generate(output_dir="output/")
    .report()
)
```

## Event System (extensible)

```python
from comic_maker import ComicEngine, ComicEvent

engine = ComicEngine()
engine.on(ComicEvent.ANALYZE_START, my_handler)
engine.run(source_text="Once upon a time...")
```

## Plugins

| Plugin | Name | Event | What It Does |
|--------|------|-------|--------------|
| ImageClassifierPlugin | image-classifier | ANALYZE_START | Classify images: characters, setting, style, mood |
| ImagePromptPlugin | image-prompt-generator | PROMPT_START | Reverse-engineer 4-part prompts from images |
| MotionEnhancerPlugin | motion-enhancer | SVG_RENDER | Inject motion effects: speed lines, blur, shake |

Register plugins:
```python
from comic_maker.plugins import PluginRegistry
from comic_maker.plugins_image import ImageClassifierPlugin, MotionEnhancerPlugin

registry = PluginRegistry(engine.bus)
registry.register(ImageClassifierPlugin())
registry.register(MotionEnhancerPlugin())
```

## Real-World Export

Export comics as platform-ready images:

```python
from comic_maker import Exporter

exporter = Exporter("output/")
result = exporter.export_episode(
    svg_pages=[svg1, svg2, svg3],
    episode_name="episode-01",
    platform="webtoon",  # or tapas, manga_plus, lezhin, comico
)
# result = {
#   "image_paths": [...],
#   "slice_paths": [...],      # auto-sliced for vertical scroll
#   "thumbnails": {...},        # 1080x1080 + 1080x1920 + 160x151
#   "cbz_path": "output/episode-01.cbz",
#   "total_size_mb": 4.2,
#   "within_size_limit": True,
# }
```

Platform profiles:

| Platform | Width | Format | Max/File | Max/Episode |
|----------|-------|--------|----------|-------------|
| WEBTOON | 800px | JPG | 2MB | 20MB |
| TAPAS | 800px | JPG | 2MB | 20MB |
| MANGA_PLUS | 1920px | PNG | 5MB | 100 pages |
| LEZHIN | 720px | JPG | 2MB | — |
| COMICO | 800px | JPG | 2MB | 20MB |

## Workflow (8 ขั้นตอน)

ดูรายละเอียดที่ [references/workflow.md](references/workflow.md)

```
1: วิเคราะห์เนื้อหา → analysis.md
2: ยืนยันตัวเลือก — Genre → Style → Tone (⚠️ ห้ามข้าม)
3: สตอรี่บอร์ด (nemū) → ตัวละคร → foreshadowing
4: [Optional] ตรวจโครงร่าง
5: สร้าง Prompt — 4-part formula (Subject+Action+Env+Style)
6: [Optional] ตรวจ Prompt
7: สร้างภาพ + Export → JPG/PNG/CBZ
8: รายงาน
```

## Options

- **Genre**: shonen, shojo, seinen, josei, kodomo + 15 genres → [references/genres/](references/genres/)
- **Art**: 14 styles → [references/art-styles/](references/art-styles/)
- **Tone**: 16 tones → [references/tones/](references/tones/)
- **Layout**: 8 layouts → [references/layouts/](references/layouts/)
- **Page size**: webtoon (800px scroll) / manga B5 / western

## Key Rules

| Rule | Detail |
|------|--------|
| **Cover first** | ปกมาก่อนทุกอย่าง |
| **Canonical copy** | คำอธิบายตัวละคร copy-paste จาก canonical table |
| **引きทุกหน้า** | ทุกหน้าต้องมี page-turn hook |
| **Portable prompt** | 4-part formula — ใช้กับ image gen ไหนก็ได้ |
| **Anti-slop** | dialogue/narration ต้องไม่คำ banned |
| **Real output** | Export เป็น JPG/PNG/CBZ พร้อม upload แพลตฟอร์ม |

## References

- `GLOSSARY.md` — คำศัพท์: nemū, 引き, portable, canonical
- `references/workflow.md` — 8-step workflow details
- `references/base-prompt.md` — Portable prompt template
- `references/analysis-framework.md` — Content genre analysis
- `references/auto-selection.md` — Genre/style/tone recommendation
- `scripts/svg_comic.py` — SVG renderer
- `scripts/anti_slop.py` — Text quality checker
- `REAL_WORLD_PLATFORM_SPECS.md` — Platform upload requirements
