🖼️

Invitation Maker

Bulk generate personalized event invitations by inserting names from a guest list onto an image template.

Image ⭐⭐ Intermediate ⏱️ 5 minutes
📥 Download Tool

😫 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 .ttf calligraphy 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.

📦

Agentic Resource Kit

invitation-maker-new.md
⬇️ Save
---
description: Tạo thiệp mời cá nhân hóa từ danh sách khách và ảnh mẫu
---

# Invitation Maker

Tạo hàng loạt thiệp mời cá nhân hóa với tên khách mời từ file Excel, đặt lên ảnh template.

## Mục tiêu
- Tạo N file ảnh thiệp mời (1 file/khách)
- Tên khách được đặt đúng vị trí và font theo config

## Input bắt buộc ⚠️

> **DỪNG LẠI VÀ KIỂM TRA** trước khi thực hiện bất kỳ bước nào!
> Nếu thiếu input → HỎI LẠI user ngay. KHÔNG tự suy đoán.

| #   | Input           | Mô tả                                     | Ví dụ                                  |
| --- | --------------- | ----------------------------------------- | -------------------------------------- |
| 1   | Ảnh mẫu thiệp   | File PNG/JPG làm nền                      | `template.png`                         |
| 2   | Danh sách khách | File Excel (.xlsx), cột đầu tiên chứa tên | `guests.xlsx`                          |
| 3   | Font chữ        | Tên font hoặc đường dẫn .ttf              | `Roboto`, `C:/Windows/Fonts/arial.ttf` |

**Câu hỏi mẫu:**
```
Để tạo thiệp mời, tôi cần các thông tin sau:
1. Đường dẫn đến ảnh mẫu thiệp (PNG/JPG)?
2. Đường dẫn đến file Excel danh sách khách mời?
3. Font chữ muốn sử dụng (tên font hoặc file .ttf)?
```

---

## Các bước thực hiện

### Bước 1: Kiểm tra thư mục làm việc
// turbo
```bash
ls -la
```

### Bước 2: Tìm và xác nhận Font

**Ưu tiên 1 - Font hệ thống (Windows):**
// turbo
```powershell
Get-ChildItem "C:\Windows\Fonts" -Filter "*[TÊN_FONT]*" -ErrorAction SilentlyContinue
```

**Ưu tiên 2 - Font trong project:**
```bash
ls fonts/
```

**Ưu tiên 3 - Tải từ Google Fonts:**
```powershell
# Roboto
Invoke-WebRequest -Uri "https://github.com/googlefonts/roboto/releases/download/v2.138/roboto-unhinted.zip" -OutFile roboto.zip
Expand-Archive -Path roboto.zip -DestinationPath fonts -Force

# Be Vietnam Pro
Invoke-WebRequest -Uri "https://fonts.google.com/download?family=Be%20Vietnam%20Pro" -OutFile bevietnam.zip
Expand-Archive -Path bevietnam.zip -DestinationPath fonts -Force
```

### Bước 3: Tạo/Cập nhật config.json

```json
{
    "input_excel": "danh-sach.xlsx",
    "template_image": "template.png",
    "output_dir": "invitations",
    "font_settings": {
        "path": "C:/Windows/Fonts/arial.ttf",
        "size": 60,
        "color": [255, 165, 0]
    },
    "text_position": {
        "y": 330,
        "center_x": 600
    }
}
```

### Bước 4: Cấu hình vị trí text (Tùy chọn)

```bash
python web_server.py
```
Mở `http://localhost:8000`, kéo thả text, nhấn Save.

### Bước 5: Tạo thiệp mời
// turbo
```bash
python generate_invitations.py
```

### Bước 6: Kiểm tra kết quả
// turbo
```bash
ls invitations/
```

---

## Output mong đợi
- Thư mục `invitations/` chứa N file PNG
- Mỗi file có định dạng: `invitation-[Tên khách].png`

## Tham khảo nhanh

### Font Windows có sẵn
| Font            | Đường dẫn                      |
| --------------- | ------------------------------ |
| Arial           | `C:/Windows/Fonts/arial.ttf`   |
| Arial Bold      | `C:/Windows/Fonts/arialbd.ttf` |
| Times New Roman | `C:/Windows/Fonts/times.ttf`   |
| Segoe UI        | `C:/Windows/Fonts/segoeui.ttf` |
| Tahoma          | `C:/Windows/Fonts/tahoma.ttf`  |

### Màu phổ biến (RGB)
| Màu       | RGB               |
| --------- | ----------------- |
| Trắng     | `[255, 255, 255]` |
| Vàng Gold | `[255, 215, 0]`   |
| Cam       | `[255, 165, 0]`   |
| Đỏ        | `[255, 0, 0]`     |

## Xử lý lỗi / Edge cases

| Tình huống                   | Cách xử lý                                  |
| ---------------------------- | ------------------------------------------- |
| Font không hỗ trợ tiếng Việt | Đổi sang Arial hoặc Roboto                  |
| Excel không có cột "Name"    | Dùng cột đầu tiên                           |
| Font không tìm thấy          | Tải từ Google Fonts hoặc dùng font hệ thống |
| Tên khách quá dài            | Giảm `font_size` trong config               |

Prompt:

“I have guests.csv (with ‘Name’ column) and template.jpg. Write a Python script using Pillow to:

  1. Font Handling:
    • Try loading custom_font.ttf from the same folder.
    • Fallback to system Arial or DejaVuSans if not found.
    • Use font size 60px.
  2. 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.).
  3. 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

  1. Copy Prompt → Paste to AI → Run generated script.
  2. Click text position → Load guest list → Generate all.

Related Workflows

Explore other categories

Ready to use this workflow?

📥 Download Tool
📬

Get Started with Agentic Working

Subscribe to receive updates from AgenticWorking.io

📖 Free eBook Guide 📦 7 Ready-to-use Scripts 🔔 Weekly Tips

No spam, unsubscribe anytime. Join 1,000+ subscribers.