😫 Vấn đề (The Pain Point)
Bạn kinh doanh trên Shopee/Lazada. Sàn yêu cầu ảnh phải vuông (1000x1000px). Đồng thời, bạn muốn chèn Logo shop vào góc ảnh để chống bị đối thủ trộm ảnh.
Cách làm thủ công:
- Mở Photoshop/Canva.
- Tạo canvas vuông.
- Kéo ảnh sản phẩm vào, chỉnh kích thước.
- Kéo Logo vào, chỉnh độ mờ (Opacity).
- Lưu file.
- Lặp lại cho 500 sản phẩm… (Mất cả ngày!)
🚀 Giải pháp Agentic (The Solution)
Bạn sẽ sở hữu một Mini-Photoshop chuyên dụng cho việc này.
Tính năng:
- Visual Editor: Kéo thả Logo trực tiếp trên màn hình để đặt vị trí (không cần đoán tọa độ).
- Smart Resize: Ảnh chữ nhật sẽ tự động được thêm nền trắng (padding) để thành hình vuông, không bị cắt cúp hay méo hình.
- Batch Processing: Xử lý 1000 ảnh trong khi bạn đi pha cà phê.
- Config: Lưu lại cấu hình cho lần sau.
(Giao diện thực tế App sẽ được Python tạo ra)
🤖 Engineering Prompt (Copy & Paste)
Copy đoạn prompt này để tạo công cụ:
**Role:** Python GUI Developer
**Task:** Create a robust Desktop App for batch image processing (Resize & Watermark).
**Requirements:**
1. **Tech Stack:** Python, `tkinter` (Modern GUI), `Pillow` (PIL) for image processing.
2. **Core Features:**
* **Visual Editor:** allow users to drag-and-drop a watermark logo onto a sample image to define position.
* **Controls:** Sliders for Opacity (0-100%) and Logo Scale (Size).
* **Native File Selection:** Buttons to select "Input Folder", "Output Folder", and "Watermark File" using system dialogs (overcoming HTML browser security limitations).
* **Settings Persistence:** Save the configuration (paths, position, opacity) to `config.json` so the user doesn't have to re-select every time.
3. **Processing Logic (Run Batch):**
* Iterate through all images in the Input Folder.
* Resize main image to 1000x1000px (contain/fit mode).
* Add white padding (canvas) to make it a perfect square if needed.
* Apply the watermark at the exact coordinates and opacity defined in the Visual Editor.
* Save to Output Folder.
4. **Deliverables:**
* `setup_gui.py`: The main Tkinter application.
* `requirements.txt`: Dependencies.
* `run.bat`: Launcher.
**Context:** Used by e-commerce sellers to process hundreds of product photos for Shopee/Lazada (requiring square images + logo).
🧠 Giải mã Prompt (Anatomy)
- Input/Output rõ ràng: Giải quyết vấn đề bảo mật của trình duyệt web (không đọc được full path) bằng cách dùng Python (
native file selection). - Settings Persistence: Yêu cầu lưu file
config.jsongiúp bạn không phải chọn lại folder mỗi lần mở app. Đây là tính năng của phần mềm thương mại. - Visual Editor: Thay vì gõ tọa độ (x=100, y=200), chúng ta yêu cầu AI làm tính năng kéo thả.
🛠️ Hướng dẫn sử dụng (Zero-Touch Guide)
- Copy Prompt ở trên.
- Paste vào AI Editor.
- Chạy file
run.batđược tạo ra. - Trên giao diện App:
- Chọn folder ảnh gốc (Input).
- Chọn file Logo.
- Kéo logo vào vị trí ưng ý trên ảnh mẫu.
- Bấm Start Processing.
Bạn đã có ngay bộ ảnh chuẩn SEO sàn TMĐT!