Skip to main content

Python Prompt to Build an Image Processing and Watermarking Pipeline

Build a Python image-processing pipeline for batch resizing, format conversion, watermarking, thumbnail generation, and metadata management at scale.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Build a Python image processing pipeline for e-commerce product image processing for web and mobile. The pipeline processes 2,000 images daily with an average size of 5MB (JPEG from professional cameras). Use Python 3.12 with Pillow with libvips for large images. Implement: 1) Create a processing pipeline class with a builder pattern: Pipeline().resize(1200x1200 max for web, 600x600 for thumbnails, 150x150 for previews).convert(WebP with JPEG fallback).watermark(semi-transparent brand logo in bottom-right corner).optimize(balance quality and size, targeting under 200KB per image).save(./processed/{date}/{product_id}/{size}.{format}). Each step should be optional and chainable. Document the pipeline with clear method signatures and return types. 2) Implement image resizing with 4 (fit, fill, exact, thumbnail): fit (scale to fit within dimensions, preserve aspect ratio), fill (crop to fill dimensions, configurable anchor point), exact (force dimensions, may distort), and thumbnail (smart crop using entropy-based center detection to detect the focal point). Support batch generation of 4 size variants from a single source. 3) Build format conversion supporting: JPEG (configurable quality 85 for web, 95 for print, progressive loading, EXIF orientation fix), PNG (palette optimization for simple graphics), WebP (lossy and lossless with quality parameter), and AVIF if yes, using pillow-avif-plugin. Implement automatic format selection based on image content (photographs get JPEG/WebP, graphics with transparency get PNG/WebP). 4) Add watermarking: text watermark with the brand name using configurable font, size, opacity (30%), position (9-grid placement), and rotation. Image watermark with overlay blending. Implement a tiled watermark pattern for full-image coverage. 5) Create metadata management: read EXIF/IPTC/XMP data, strip sensitive metadata (GPS, camera serial) for privacy, preserve copyright and attribution fields, and inject custom metadata fields product_id, sku, processing_date, and pipeline_version. 6) Build batch processing with concurrent.futures.ProcessPoolExecutor with 6 workers — process images from an S3 bucket (s3://product-images/raw/), apply the configured pipeline, save results to organized by date and product ID, generate a processing report (total, successful, failed, skipped duplicates), and implement resume capability using file hash tracking. 7) Add quality assurance: validate output images are not corrupted (can be re-opened), verify dimensions match specs, check file sizes are within web: 200KB, thumbnail: 30KB, preview: 10KB, and generate a visual comparison grid of before/after for spot-checking.

What this prompt does

This prompt makes the AI design and build a complete Python image-processing pipeline tailored to your [use_case], sized for the throughput you declare in [daily_volume] and [avg_file_size]. It pins the toolchain with [python_version] and [image_library], then asks for a chainable builder API where each step — resize, convert, watermark, optimize, save — is optional and composable. Because you state the volume and average file size up front, the AI can reason about concurrency and memory instead of producing toy code that falls over on real batches.

The structure works because it forces concrete decisions at every layer. [resize_modes] and [smart_crop_method] define how variants are derived from a source; [output_format], [jpeg_quality], and [avif_support] control encoding tradeoffs; [watermark_text] and [watermark_opacity] shape branding; and [custom_metadata] plus the EXIF-stripping rules cover privacy. The [concurrency_type], [input_source], and [output_structure] variables turn it from a single-image script into a batch system with a processing report and resume-by-hash recovery. The [size_variants] and [size_limits] variables push the AI to derive a fixed set of outputs per source and enforce a ceiling on each, while the automatic-format-selection logic decides between JPEG, WebP, PNG, and AVIF based on whether an image is a photograph or a graphic with transparency. Spelling out [quality_target] keeps the encoder from optimizing for size at the expense of visible artifacts, or the reverse.

When to use it

  • You run an e-commerce or media app where every upload needs several optimized variants
  • You need to strip GPS and camera-serial metadata before publishing images publicly
  • You want WebP or AVIF output with a JPEG fallback to cut delivery size
  • You process thousands of files per run and need resume capability after a crash
  • You need smart-cropped thumbnails that keep the focal point instead of blind center crops
  • You want a quality-assurance pass that catches corrupted output before it ships

Example output

The AI returns a structured Python codebase: a Pipeline class exposing the chainable builder methods, supporting modules for resizing, format conversion, watermarking, and metadata handling, plus a batch runner that reads from [input_source], writes to [output_structure], and emits a processing report (total, successful, failed, skipped duplicates). Expect method signatures with return types, a hash-tracking resume mechanism, and a QA step that re-opens output to confirm it is not corrupt.

Pro tips

  • Set [avg_file_size] honestly — large source files are why the prompt suggests libvips alongside Pillow in [image_library]
  • Match [concurrency_type] to your CPU count; a ProcessPoolExecutor with too many workers thrashes on memory-heavy images
  • Be explicit in [resize_specs] and [size_variants] so the AI generates the exact variant set your CDN expects
  • Keep [quality_target] and [size_limits] aligned — asking for under 200KB while demanding quality 95 will conflict
  • Name real fields in [custom_metadata] (product_id, sku) so the injected metadata is queryable later
  • If privacy matters, double-check the AI actually strips GPS/serial fields rather than only copying copyright tags

Frequently Asked Questions

Does this prompt support generating WebP and AVIF output?
Yes. The format-conversion step covers JPEG, PNG, WebP (lossy and lossless), and AVIF when you set `[avif_support]`. It also asks for automatic format selection based on content, so photographs lean toward JPEG/WebP and graphics with transparency toward PNG/WebP.
How does the resume capability work for large batches?
The batch step tracks processed files by hash, so a rerun skips images it already finished and picks up where a crash left off. This is what makes it safe to run over thousands of files without redoing completed work each time.
Will the pipeline remove sensitive metadata like GPS location?
The metadata step explicitly strips sensitive EXIF/IPTC/XMP fields such as GPS coordinates and camera serial numbers while preserving copyright and attribution. You should still verify the generated code actually removes those fields rather than only copying the ones you want to keep.
Which image library does the generated code use?
Whatever you put in `[image_library]`; the default pairs Pillow with libvips for large images. libvips matters when `[avg_file_size]` is high because it streams large images with far less memory than Pillow alone.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Python & Automation Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support