An AI-based comic panel script generation tool that supports multi-page comic generation and image export
|
Chinese Interface |
English Interface |
|
Configuration Panel |
|
|
Chinese Comic Example |
English Comic Example |
💡 See more examples and demos in the assets folder
comic_alpha/
├── assets/ # Demo screenshots and example comics
│ ├── demos/ # UI screenshots and demos
│ └── examples/ # Generated comic examples
├── backend/ # Backend service
│ ├── app.py # Flask application entry point
│ ├── controllers/ # API controllers
│ ├── services/ # Business logic services
│ ├── static/ # Static assets (including generated images)
│ ├── pyproject.toml # Python project configuration
│ └── uv.lock # Python lock file
├── frontend/ # Frontend resources
│ ├── css/
│ │ └── style.css # Style file
│ └── js/
│ ├── i18n.js # Internationalization module
│ ├── theme.js # Theme management module
│ ├── api.js # API call module
│ ├── config.js # Configuration management module
│ ├── renderer.js # Rendering module
│ ├── pageManager.js # Page management module
│ ├── sessionManager.js # Session management module
│ ├── exporter.js # Image export module
│ └── app.js # Main controller
├── index.html # Main page
├── start.sh # Startup script for Linux/macOS
└── start.bat # Startup script for Windows
- Python 3.8+
- Flask: Web framework
- OpenAI API: AI generation capabilities
- Flask-CORS: Cross-origin support
- Vanilla JavaScript: Modular design
- HTML5 + CSS3: Interface
- html2canvas: Image export
Run the one-click startup script:
# For macOS/Linux
chmod +x start.sh
./start.sh
# For Windows
start.batThis project uses uv for fast dependency management.
cd backend
# Sync dependencies using uv (automatically creates a virtual environment)
uv sync# Run the application using uv
uv run app.pyThe backend service will start at http://localhost:5003.
Use a local server:
# Start a simple HTTP server using Python
python -m http.server 8000Then visit http://localhost:8000
- Click the 🌙/☀️ button in the top right corner to switch between dark mode and light mode
- Theme preferences are automatically saved to local storage
- If no preference is set, it will automatically follow the system theme
- Click the language selector in the top right corner to switch between Chinese and English
- Supported languages: Chinese (Simplified), English
- Language preferences are automatically saved
- Click the ⚙️ Settings button in the top right corner
- Google API Key (Mandatory): Enter your Google API Key. This is required for core script generation and smart features.
- Advanced Settings (Optional): Click to expand if you want to use OpenAI models:
- Enter your OpenAI API Key
- Enter the OpenAI API Base URL (default:
https://api.openai.com/v1) - Select an OpenAI model (e.g.,
gpt-4o-mini)
- Click 💾 Save Configuration
- Ensure your API is configured (specifically the Google API Key)
- Describe the comic content you want in the text box (supports direct image paste as a reference)
- Set the number of pages to generate (1-10 pages)
- Click AI Generate Multi-page Panels
- Wait for generation to complete
- Use the ← Previous Page / Next Page → buttons to browse multi-page comics
- You can directly edit the JSON script, then click Generate Panels to re-render
- Click 🎨 Generate Current Page Comic to convert the sketch into a complete comic image
- Automatically captures the current sketch as a reference image
- The generated image will maintain the layout and composition of the sketch
- Click 🎨 Generate All Pages Comics to batch generate complete comics for all pages
- Automatically iterates through all pages, generating complete comics page by page
- Intelligently uses previous pages as references to maintain character and style consistency
- Click 🎨 Generate Cover to create a stunning cover for your comic
- Automatically uses generated story pages as references
- Ensures character consistency between the cover and the story
- Click 📱 Generate Xiaohongshu Content to automatically generate content suitable for Xiaohongshu publishing
- Automatically generates attractive titles based on comic content
- Generates 200-500 word body content with emojis and paragraphs
- Automatically generates 5-8 relevant topic tags
- Supports one-click copy of all content
- Click Download Current Page to export a single page sketch
- Click Download All Pages to batch export all sketch pages
The project includes a powerful reference image system to ensure consistency and high quality:
- Mechanism: The system supports pasting images (directly via Ctrl+V in the prompt box) or using previously generated pages as references for the AI.
- Benefit: The AI extracts details like facial features, hairstyles, clothing, and specific props, ensuring characters remain consistent throughout the entire comic series without unexpected "face changes" or outfit swaps.
- Mechanism: The live sketch preview (rendered from the JSON script) is used as a layout reference for the AI.
- Benefit: The AI precisely replicates the panel layout, character positions, and composition from the sketch, achieving a "what you see is what you get" result.
- Mechanism: When generating a cover, all story pages are used as references.
- Benefit: This ensures the characters and art style on the cover perfectly match the content of the comic, creating a professional and cohesive look.
GET /api/health
Response:
{
"status": "ok",
"message": "Comic generator API is running"
}POST /api/generate
Request Body:
{
"google_api_key": "your-google-api-key",
"api_key": "your-openai-api-key (optional)",
"prompt": "Describe comic content",
"page_count": 3,
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini"
}Response:
{
"success": true,
"pages": [...],
"page_count": 3
}POST /api/validate
Request Body:
{
"script": {...}
}Response:
{
"valid": true
}POST /api/generate-image
Request Body:
{
"page_data": {
"title": "Page Title",
"rows": [...]
},
"reference_img": "data:image/png;base64,...",
"extra_body": {}
}Notes:
reference_imgwill automatically pass the base64 data of the current sketch- The generated image will reference the layout and composition of the sketch
- Supports base64 format and URL format
Response:
{
"success": true,
"image_url": "Generated image URL",
"prompt": "Prompt used"
}POST /api/generate-xiaohongshu
Request Body:
{
"google_api_key": "your-google-api-key",
"api_key": "your-openai-api-key (optional)",
"comic_data": [
{
"title": "Page 1 Title",
"rows": [...]
}
],
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini"
}Notes:
comic_datacan be a single page object or an array of pages- Automatically extracts comic content and generates copy suitable for Xiaohongshu
- Generated content includes title, body, and tags
Response:
{
"success": true,
"title": "Attractive Title ✨",
"content": "Body content with emojis and paragraphs...",
"tags": ["comic", "AI creation", "Xiaohongshu", ...]
}- Supports multi-language switching (Chinese/English)
- Uses localStorage to persist language preferences
- Provides translation functions and UI update mechanisms
- Supports dark/light mode switching
- Automatically detects system theme preferences
- Uses localStorage to persist theme settings
- Smooth theme transition animations
- Manages user configuration (API Key, Base URL, Model)
- Uses localStorage for persistent storage
- Encapsulates all backend API calls
- Unified error handling
- Renders JSON data into comic panels
- Supports custom styles
- Manages multi-page comic state
- Provides page navigation functionality
- Manages multiple generation sessions
- Persists session data (script, images, settings) to localStorage
- Supports session creation, selection, and deletion
- Single page export
- Batch export
- Uses html2canvas to generate high-quality images
- Coordinates all modules
- Handles user interactions
- Manages application state
{
"title": "Comic Title",
"rows": [
{
"height": "180px",
"panels": [
{ "text": "Panel description text" },
{ "text": "Another panel", "bg": "#f0f0f0" }
]
}
]
}title: Page title (optional)rows: Array of panel rowsheight: Row height (default 150px)panels: Array of panelstext: Panel description textbg: Background color (optional)
- Backend Features: Add new routes in
backend/app.py - Frontend API: Add corresponding call methods in
frontend/js/api.js - UI Interactions: Add control logic in
frontend/js/app.js
Edit the frontend/css/style.css file to modify the interface styles.
Modify the _createPanel method in frontend/js/renderer.js to support more panel styles.
A: Make sure the backend service is running (python backend/app.py), and check if the Base URL configuration is correct.
A: Select "Custom Model" in the configuration panel, then enter the model name (e.g., kimi-k2).
A: Make sure the html2canvas library is loaded, and check the browser console for error messages.
A:
- Deploy the backend using Gunicorn or uWSGI
- Host the frontend using Nginx or another web server
- Configure CORS to allow the frontend domain to access the backend
MIT License
Issues and Pull Requests are welcome!




