-
Couldn't load subscription status.
- Fork 2
Generate Images
Updated for:
-
β Default paths for prompt file and output directory
-
β Chapter-based prompts
-
β Character profile injection
-
β Style override support
-
β CLI overrides (e.g., API key)
-
β Auto-skip existing images
| Task | File / Script | Description |
|---|---|---|
| π§ Generate images | scripts/generate_images.py |
Creates images using DeepAI based on structured JSON prompt files |
| βοΈ Inject into chapters | scripts/inject_images.py |
Inserts  tags into Markdown files |
| π§° Character descriptions | scripts/data/character_profiles.json |
Stores reusable character descriptions for image prompts |
| π§° Prompt JSON file | scripts/data/image_prompts.json |
Default prompt template with chapters, characters, and prompts |
project-root/
βββ manuscript/
β βββ chapters/
β βββ 01-holiday-in-ohio.md
β βββ ...
βββ assets/
β βββ illustrations/ β πΌ Output images (default)
β βββ prompts/
β βββ holiday_ch1_prompts.json β Alternative prompt file (optional)
βββ scripts/
β βββ generate_images.py β π§ Image generation logic
β βββ inject_images.py β βοΈ Markdown image injection
β
βββ scripts/data/
β βββ character_profiles.json β Character descriptions
β βββ image_prompts.json β Default prompt file used by script
β
βββ .env β Set your API key here
- Install dependencies
poetry install- Set your DeepAI API key in
.env
DEEPAI_API_KEY=your_deepai_key_here- Optional: Register CLI shortcuts
[tool.poetry.scripts]
generate-images = "scripts.generate_images:main"
inject-images = "scripts.inject_images:main"The file must define a style and a list of chapters. Each chapter contains image prompts with optional character references.
Example (scripts/data/image_prompts.json):
{
"style": "comic book, colorful, cinematic lighting",
"chapters": [
{
"title": "Chapter 1 β Arrival",
"prompts": [
{
"character": ["Chris", "Das Auto"],
"prompt": "driving toward a city sign that says 'Welcome to Ohio', excited faces",
"filename": "holiday_ch1_01_arrival.png"
},
{
"character": "Hotelbesitzer",
"prompt": "lurking behind the hotel desk, eyes glowing",
"filename": "holiday_ch1_04_owner.png"
}
]
}
]
}Stored in scripts/data/character_profiles.json:
{
"Chris": "a cartoon boy around 13 years old, clever, casual travel clothes, comic style",
"Das Auto": "a shiny red convertible with a white racing stripe",
"Hotelbesitzer": "a creepy cartoon hotel owner with glowing eyes and wild hair, comic horror"
}poetry run generate-imagesThis uses:
-
Prompt file:
scripts/data/image_prompts.json -
Output directory:
assets/illustrations
poetry run generate-images \
--prompt-file assets/prompts/holiday_ch1_prompts.json \
--output-dir assets/illustrationspoetry run generate-images \
--api-key sk-your-deepai-keyIf --api-key is omitted, the script uses the value from .env.
poetry run inject-imagespoetry run inject-images --dry-runAdds image markdown like:
π Chapters processed: 1
π§ Prompts in total: 5
β
Images generated: 4
βοΈ Skipped (exists): 1
β Errors: 0
-
Use consistent filenames like
holiday_ch1_01_arrival.png -
Define default prompt styles to unify your visual output
-
Separate characters from prompts for modularity
-
Use
--api-keyto override or rotate credentials -
Works great with
inject-imagesand Pandoc/HTML exporters
- π Home
- Project Initialization
- Generate Project Structure
- How to Write a Book
- Developer Workflow & Makefile
- Chapter File Generator
- Generate Images
- Convert Markdown Images
- Bulk Change File Extensions
- Restructure Chapters
- Translate Markdown with DeepL
- Translate with LM Studio
- Translation CLI Commands
- Shortcuts for Translation
- Automatic Book Export
- Shortcuts for Export
- Export HTML Chapters (Comics)
- Export to EPUB 2
- Pandoc Batch Processor
- Export HTML Books to PDF (KDP Ready)
Use this sidebar to navigate all key workflows β from setup to translation, export, and testing.