😫 The Pain Point
E-commerce managers often have folders full of product images with different sizes and aspect ratios. Uploading these to a website (which usually requires uniform 1000x1000 squares) looks messy. Manually resizing and adding a logo to 500+ images in Photoshop takes hours.
🚀 Agentic Solution
A “Smart Image Processor” that standardizes your entire catalog in seconds with full progress tracking.
Key Features:
- Smart Padding: Adds white borders instead of cropping, preserving the whole product.
- Auto-Scaling: Resizes your watermark so it never covers the product, regardless of image size.
- Batch Processing: Handles thousands of images with progress bar and ETA.
- Error Handling: Skips corrupt images with warnings instead of crashing.
⚔️ Phase 1: Commander (Quick Fix)
For a quick one-off batch.
Prompt:
“I have a folder named
inputcontaining varied product images (JPG, PNG). I also have awatermark.pngfile.Write a robust Python script using Pillow to process these images:
- Smart Resize: Resize every image to fit within a 1000x1000 pixel canvas without cropping.
- Maintain original aspect ratio.
- Fill any empty space with a white background.
- Ensure the final output is exactly 1000x1000.
- Watermark:
- Overlay
watermark.pngin the center of the image.- Auto-scale: If the watermark is larger than 30% of the canvas width, resize it down to 30% width (maintain aspect ratio).
- Apply 50% opacity to the watermark.
- Output: Save processed images to an
outputfolder as JPG (quality=90). Handle RGBA to RGB conversion correctly.Print a progress log (e.g., ‘Processed 1/500…’). Skip corrupt images with warning.”
Result: A script that processes 500 images in < 1 minute with full error handling.
🏗️ Phase 2: Architect (Permanent Tool)
For regular use by content teams.
Engineering Prompt:
*Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create a Cross-Platform Desktop App named "E-commerce Watermark Pro".
**Objective:** A standalone desktop tool to visually position a watermark on a base image and batch process a folder of images.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Must ensure cross-platform compatibility for Windows & macOS).
* Image Processing: Pillow (PIL).
* Packaging: PyInstaller.
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* Left Panel: Controls (Load Images, Opacity/Scale Sliders, Start Button).
* Right Panel: Interactive Canvas (QGraphicsScene) for Drag & Drop positioning of the watermark.
* *Constraint:* Use standard PyQt6 widgets so they render natively on both OS.
2. **Batch Processing Logic:**
* Smart Resize to 1000x1000 (White padding).
* Apply watermark based on visual coordinates.
* Multithreading: Use `QThread` to prevent the UI from freezing during batch processing (Critical for macOS specifically to avoid the "Beachball of Death").
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Create a `build_app.py` or provide specific `pyinstaller` terminal commands to generate:
* `.exe` (Single file) for Windows.
* `.app` bundle for macOS.
🧠 Prompt Decoding
- Smart Resize: The request “fit within 1000x1000 without cropping” tells the AI to calculate aspect ratios and apply padding (
ImageOps.padin Pillow), avoiding distorted images. - Auto-scale: Essential for batch processing. Determining watermark size relative to the canvas (e.g., “30% width”) prevents it from being tiny on 4K images or huge on thumbnails.
🛠️ Instructions
- Put images in
input/folder. - Run the script or use the visual setup tool.
- Check
output/for standardized, watermarked images.