๐Ÿ–ผ๏ธ

Auto Crop Square

Automatically detect the subject in a photo and crop it to a perfect square (1:1), centered on the face or object.

Image โญโญ Intermediate โฑ๏ธ 5 minutes

๐Ÿ˜ซ The Pain Point

You have 100 raw portraits (rectangular 4:3). You need to crop them all to squares (1:1) for avatar uploads. If you simple โ€œCenter Cropโ€, you might cut off part of the head or the chin if the person is not standing exactly in the middle.

๐Ÿš€ Agentic Solution

Smart Cropping Tool: It โ€œlooksโ€ for the face/subject first, calculates the bounding box, and then crops a square around that center.

Key Features:

  • Face Detection: Uses OpenCV (Haar Cascade) to find faces.
  • Smart Padding: If the face is too close to the edge, it adds padding instead of cropping tightly.

โš”๏ธ Phase 1: Commander (Quick Fix)

For cropping a single batch of headshots.

Prompt:

โ€œI have a folder of portraits. Use OpenCV to detect the face in each photo and crop a 500x500 square centered on the face. If no face is found, just crop the center. Save to โ€˜Croppedโ€™ folder.โ€

Result: A folder of perfectly centered avatars.

๐Ÿ—๏ธ Phase 2: Architect (Permanent Tool)

For HR/School Admins.

Engineering Prompt:

**Role:** Python Computer Vision Dev
**Task:** Create a "Face-Centric Square Cropper".
**Requirements:**
1.  **GUI:**
    *   Select Input Folder.
    *   Target Size (e.g., 500px).
    *   "Start Processing" button.
2.  **Logic:**
    *   Load `haarcascade_frontalface_default.xml`.
    *   Detect face coordinates (x, y, w, h).
    *   Calculate the center of the face.
    *   Crop a square region around that center.
    *   Handle cases where the square goes out of bounds (add padding).
3.  **Deliverables:** `smart_crop.py`, `run.bat` (Windows), `run.sh` (Mac).

๐Ÿง  Prompt Decoding

  • Haar Cascade: An old but very fast and efficient algorithm for face detection. Itโ€™s built into OpenCV, meaning you donโ€™t need heavy deep learning models like YOLO for this simple task.

๐Ÿ› ๏ธ Instructions

  1. Copy Prompt -> Paste -> Run.
  2. Select Folder -> Start.

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.