🖼️

Auto Crop to Square

Automatically crop images to perfect squares using smart center detection or padding.

Image ⭐ Beginner ⏱️ 3 minutes

😫 The Pain Point

E-commerce platforms require square product images. Your catalog has mixed aspect ratios - some landscape, some portrait. Manually cropping each image to center the product takes forever.

🚀 Agentic Solution

A Smart Cropper that detects the best center point and crops or adds padding automatically.

Key Features:

  • Smart Center: Detects product position and centers the crop.
  • Padding Option: Adds white/transparent padding instead of cropping.
  • Batch Processing: Handles entire folders with progress tracking.

⚔️ Phase 1: Commander (Quick Fix)

For quick cropping.

Prompt:

“I have a folder products with varied aspect ratio images. Write a Python script using Pillow to:

  1. Crop Mode: Center-crop each image to a perfect square (use shorter dimension).
  2. Alternative Padding Mode: Or add white padding to make square (preserving full image).
  3. Output: Save to squared/ folder as JPG (quality=90).
  4. Error Handling: Skip corrupt files with warning.

Print progress log. Accept --mode crop or --mode pad argument.”

Result: Perfectly square images ready for upload.

🏗️ Phase 2: Architect (Permanent Tool)

For Content Teams.

Engineering Prompt:

**Role:** Python Tool Developer
**Task:** Create a "Smart Square Cropper".

**Requirements:**
1.  **GUI:**
    *   Select folder.
    *   Mode: Crop (center) vs Pad (white/transparent).
    *   Target size (default 1000x1000).
    *   Preview before/after.
    *   Progress bar.

2.  **Logic:**
    *   Calculate crop box from center.
    *   Handle RGBA for transparent padding.
    *   Skip corrupt files gracefully.

3.  **Deliverables:**
    *   `auto_crop.py`
    *   `run.bat`, `run.sh`
    *   `requirements.txt`

🧠 Prompt Decoding

  • Center Crop vs Padding: Two different use cases. Crop loses data but looks cleaner. Padding preserves everything but may look less polished.

🛠️ Instructions

  1. Copy Prompt → Paste → Run.
  2. Choose mode → Process folder.

Related Workflows

Explore other categories

📬

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.