Katkat

Implement Parallel Image Processing

AnthropicSoftware Engineer · Onsite

Last updated

This question evaluates competency in concurrent and parallel processing, practical image manipulation with Python libraries (Pillow), resource management for memory and file I/O, robust error handling, and performance measurement.

Build an image-processing utility in Python using the Pillow library.

You are given a collection of image file paths and an output directory. For each image, apply the following transformations:

  1. Convert the image to grayscale.
  2. Scale or resize the image to a target size while preserving correctness.
  3. Save the processed image to the output directory.

Start with a solution that works for a small number of small images. Then extend the solution so it can efficiently process many large images.

Discuss and implement an approach using parallelism or concurrency, such as ProcessPoolExecutor, and explain why it helps or does not help for this workload. Consider error handling, memory usage, file I/O, and how you would measure performance.