😫 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:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "Bulk Invitation Generator" Desktop App
**Objective:** A visual tool to design invitation layouts and clear-generate hundreds of personalized image files.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Graphics: Pillow (drawing), Pandas (data)
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Tab 1 - Design:**
* Canvas to load Template Image.
* **Interactive Dragger:** Drag a "Placeholder Name" text box to set (X, Y) coordinates.
* **Properties:** Font Family (Dropdown), Size (Spinbox), Color (Color Dialog).
* **Tab 2 - Generate:**
* Load CSV (Guests).
* "Generate" Button and Progress Bar.
2. **Core Logic:**
* Capture X,Y coordinates relative to image size from the Design tab.
* Map font settings to Pillow `ImageDraw` commands.
* **Threading:** Generation loop runs in `QThread` to prevent UI freeze.
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Windows: `pyinstaller --onefile --noconsole main.py`
* macOS: `pyinstaller --windowed --noconsole main.py`
🧠 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.