😫 The Pain Point
Year End Party is coming. You need to send digital invites to 200 staff. “Dear [Mr. John], You are invited…”. A blank template is easy, but making 200 personalized JPEGs with different fonts and handling long names?
🚀 Agentic Solution
“Mail Merge” for Images: Fill in the blank spots on an image programmatically with smart text handling.
Key Features:
- Custom Fonts: Supports
.ttfcalligraphy fonts with automatic fallback. - Auto-fit Text: Automatically reduces font size for long names.
- Unicode Support: Handles Vietnamese, Chinese, and special characters.
⚔️ Phase 1: Commander (Quick Fix)
For a quick batch.
Prompt:
“I have
guests.csv(with ‘Name’ column) andtemplate.jpg. Write a Python script using Pillow to:
- Font Handling:
- Try loading
custom_font.ttffrom the same folder.- Fallback to system Arial or DejaVuSans if not found.
- Use font size 60px.
- Text Rendering:
- Draw each name at position (500, 300) in Red (#FF0000).
- Auto-fit: If name is longer than 20 characters, reduce font size to fit within 400px width.
- Support Unicode characters (Vietnamese, Chinese, etc.).
- Output: Save as
output/Invite_{Name}.jpg(sanitize filename for special characters).Print progress log (e.g., ‘Generated 1/200: Nguyen Van A’).”
Result: 200 custom invites with proper text handling.
🏗️ Phase 2: Architect (Permanent Tool)
For HR/Event Planners.
Engineering Prompt:
**Role:** Full Stack Developer (Python + HTML)
**Task:** Create a "Bulk Invitation Generator" with Visual Config.
**Requirements:**
1. **Part 1: Visual Setup (HTML/JS)**
* File: `setup_coordinate.html` (single file, no build)
* Features:
* Upload template image preview.
* Drag & Drop "Sample Text" to set X, Y coordinates.
* Inputs: Font Size, Text Color (#Hex), Font Family preview.
* Export: Download `config.json` with all settings.
2. **Part 2: Generator Engine (Python)**
* File: `generate_invitations.py`
* Inputs: config.json, guests.csv, template.jpg
* Logic:
* Load config and iterate CSV.
* Draw text with font fallback (custom.ttf > Arial > DejaVuSans).
* **Progress bar** (tqdm or print log).
* Save to output/ folder.
* Handle errors gracefully (skip bad rows with warning).
3. **Deliverables:**
* `setup_coordinate.html`
* `generate_invitations.py`
* `requirements.txt` (Pillow, pandas)
* `run.bat` and `run.sh`
🧠 Prompt Decoding
- Visual Config: Coordinates (X=400, Y=300) are abstract. The “Click on image” requirement bridges the gap between code and design, making the tool usable for non-coders.
- Font Fallback: Essential for cross-platform compatibility. Not all systems have the same fonts installed.
🛠️ Instructions
- Copy Prompt → Paste to AI → Run generated script.
- Click text position → Load guest list → Generate all.