😫 Vấn đề (The Pain Point)
Bạn có một folder chứa 500 ảnh chụp từ máy ảnh (6000x4000px, nặng 10MB/ảnh). Bạn cần resize tất cả về 1920px để upload lên Web hoặc gửi Zalo cho nhẹ.
Cách làm thủ công:
- Mở Paint hoặc Photoshop.
Ctrl + Alt + I(Image Size).- Gõ 1920.
- Save.
- Lặp lại 500 lần.
🚀 Giải pháp Agentic (The Solution)
Một tool nhỏ gọn, chọn folder và nhập kích thước mong muốn.
Tính năng:
- GUI Config: Chọn folder Input/Output dễ dàng.
- Resize Mode: Chọn resize theo Chiều ngang (Width), Chiều dọc (Height) hoặc % (Percentage).
- Pro Features: Tùy chọn giữ nguyên tỷ lệ (Aspect Ratio) để ảnh không bị méo.
- High Speed: Dùng đa luồng (Threading) để xử lý nhanh.
🤖 Engineering Prompt (Copy & Paste)
**Role:** Python Tool Developer
**Task:** Create a "Batch Image Resizer" desktop app.
**Requirements:**
1. **Tech Stack:** Python, `tkinter`, `Pillow`.
2. **GUI:**
* Input Folder selection.
* Output Folder selection.
* Radio buttons for Resize Mode: "By Width", "By Height", "By Percentage".
* Entry field to enter the target value (e.g., 1920 px or 50%).
* "Start" button and Progress Bar.
3. **Logic:**
* Support .jpg, .png, .jpeg.
* Maintain Aspect Ratio (High Quality resampling `LANCZOS`).
* Handle errors (skip corrupt files).
4. **Deliverables:**
* `resize_app.py`
* `run.bat`
* `requirements.txt`
**Context:** User needs to downsize heavy camera photos for web use.
🧠 Giải mã Prompt
- Resampling Method: Yêu cầu
LANCZOSđể đảm bảo ảnh sau khi thu nhỏ vẫn sắc nét, không bị vỡ hạt. - Flexible Modes: Không phải lúc nào cũng resize theo width, đôi khi cần giảm 50% dung lượng nên cần mode Percentage.
🛠️ Hướng dẫn
- Copy Prompt -> AI Editor paste.
- Chạy
run.bat. - Chọn Folder ảnh -> Chọn “By Width” -> Gõ 1920 -> Start.