πŸ–ΌοΈ

Smart Compress

Intelligently compress images to a target file size while maintaining visual quality.

Image ⭐ Beginner ⏱️ 3 minutes

😫 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 photos with large JPG images. Write a Python script using Pillow to:

  1. Target Size: Compress each image to under 500KB.
  2. Algorithm: Binary search for optimal quality (start at 85, adjust until under target).
  3. Minimum Quality: Never go below quality=30.
  4. 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 Tool Developer
**Task:** Create a "Smart Image Compressor".

**Requirements:**
1.  **GUI:**
    *   Select input folder.
    *   Target size input (KB or MB).
    *   Minimum quality slider.
    *   Resize option (max dimension).
    *   Progress bar with size savings.

2.  **Logic:**
    *   Binary search for optimal quality.
    *   Option to resize before compressing.
    *   Show total space saved.

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

🧠 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

  1. Copy Prompt β†’ Run.
  2. Set target size β†’ Compress.

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.