Case Study 7: Batch Image Processing Pipeline (Challenge)
:::info Challenge — no solution provided This case study, and the three that follow it, are open challenges. Use the same approach as the earlier case studies: design your own solution, decide on your own file/module structure, and treat the suggested libraries as a starting point rather than a strict requirement. :::
Scenario
A marketing team drops thousands of raw product photos into a shared folder. Preparing them by hand in an image editor is too slow. Your task is to automatically resize each photo into multiple standard resolutions, apply a watermark, and convert everything to a web-optimized format.
Suggested Libraries
PIL(Pillow)pathlibconcurrent.futures
Sample Files You May Create
raw_photos/— a folder of source imagesprocessed_photos/— the generated output, organized by resolution
Requirements
- Read all images from an input folder.
- Resize each image into multiple predefined resolutions.
- Preserve aspect ratio when resizing.
- Apply a watermark to each image.
- Convert output images to a web-optimized format.
- Process multiple images in parallel.
- Organize output files by resolution.
Things to think about
- Image processing is CPU-bound. Would
ThreadPoolExecutororProcessPoolExecutorbe the better fit here, and why? - How would you avoid re-processing an image that's already been converted, if the script is run again on the same folder?