😫 The Pain Point
Email attachment limit is 5MB. Your product photos are 8MB each. You need to compress them but not make them look terrible. Finding the right quality setting is trial and error.
🚀 Agentic Solution
A Smart Compressor that automatically finds the optimal quality to hit your target file size.
Key Features:
- Target Size: Specify “under 500KB” and the script finds the right settings.
- Quality Floor: Never goes below a minimum quality threshold.
- Batch Processing: Process entire folders.
⚔️ Phase 1: Commander (Quick Fix)
For quick compression.
Prompt:
“I have a folder
photoswith large JPG images. Write a Python script using Pillow to:
- Target Size: Compress each image to under 500KB.
- Algorithm: Binary search for optimal quality (start at 85, adjust until under target).
- Minimum Quality: Never go below quality=30.
- Output: Save to
compressed/folder.Print progress with original and final file sizes. Skip files already under target size.”
Result: Email-ready images that still look good.
🏗️ Phase 2: Architect (Permanent Tool)
For Marketing Teams.
Engineering Prompt:
**Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "Smart Image Compressor" Desktop App
**Objective:** A batch tool to compress images to a specific target file size (e.g., <500KB) automatically.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Image Processing: Pillow
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Input:** Folder selection.
* **Goal:** Target Size Input (KB/MB).
* **Constraints:** "Minimum Quality" Slider limit.
* **Results:** Table showing "Original Size" vs "Optimized Size" and "Space Saved".
2. **Core Logic:**
* **Binary Search:** Iteratively save to a memory buffer to find the highest quality that fits the target size.
* **Threading:** Multithreaded compression loop.
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
- Binary Search: Instead of guessing quality, the script tests 50, then 75 or 25, narrowing down to the exact quality that hits the target size.
🛠️ Instructions
- Copy Prompt → Run.
- Set target size → Compress.