PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Anthropic

Implement a Batch Image Processor

Last updated: Apr 19, 2026

Quick Overview

This question evaluates a candidate's competency in image processing operations and parallel/concurrent programming, covering basic transformations (grayscale, scale, resize) and considerations for CPU-bound batch processing.

  • medium
  • Anthropic
  • Coding & Algorithms
  • Software Engineer

Implement a Batch Image Processor

Company: Anthropic

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a program that applies basic image transformations to a batch of images. You are given a list of input image paths and, for each image, a sequence of operations to apply in order. Support the following operations: 1. **grayscale**: convert the image to grayscale. 2. **scale(factor)**: multiply both width and height by a positive floating-point scale factor. 3. **resize(width, height)**: resize the image to the exact target dimensions. ### Part 1 Write a function that processes a small batch of images correctly and saves the transformed results. Example function shape: `process_images(tasks: list[ImageTask], output_dir: str) -> list[str]` Where each `ImageTask` contains: - `input_path`: path to the source image - `operations`: ordered list of operations such as `grayscale`, `scale(0.5)`, or `resize(200, 300)` The function should return the output paths in the same order as the input tasks. ### Part 2 Now assume the images are very large and the batch size is also large. The interviewer asks you to improve performance on a multi-core machine. Update your approach so that: - multiple images can be processed in parallel, - output ordering is preserved, - a failure in one task does not corrupt other results, - the design is appropriate for CPU-heavy image processing. You may use a standard Python imaging library such as Pillow.

Quick Answer: This question evaluates a candidate's competency in image processing operations and parallel/concurrent programming, covering basic transformations (grayscale, scale, resize) and considerations for CPU-bound batch processing.

Related Interview Questions

  • Banking System Simulation - Anthropic (medium)
  • LRU Cache - Anthropic (medium)
  • Account Balance with Expiring Grants - Anthropic (medium)
  • Path Resolution with Symbolic Links - Anthropic (medium)
  • In-Memory Key-Value Database with Nested Transactions - Anthropic (medium)
|Home/Coding & Algorithms/Anthropic

Implement a Batch Image Processor

Anthropic logo
Anthropic
Apr 1, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
10
0
Practice Read
Loading...

Implement a program that applies basic image transformations to a batch of images.

You are given a list of input image paths and, for each image, a sequence of operations to apply in order. Support the following operations:

  1. grayscale : convert the image to grayscale.
  2. scale(factor) : multiply both width and height by a positive floating-point scale factor.
  3. resize(width, height) : resize the image to the exact target dimensions.

Part 1

Write a function that processes a small batch of images correctly and saves the transformed results.

Example function shape:

process_images(tasks: list[ImageTask], output_dir: str) -> list[str]

Where each ImageTask contains:

  • input_path : path to the source image
  • operations : ordered list of operations such as grayscale , scale(0.5) , or resize(200, 300)

The function should return the output paths in the same order as the input tasks.

Part 2

Now assume the images are very large and the batch size is also large. The interviewer asks you to improve performance on a multi-core machine.

Update your approach so that:

  • multiple images can be processed in parallel,
  • output ordering is preserved,
  • a failure in one task does not corrupt other results,
  • the design is appropriate for CPU-heavy image processing.

You may use a standard Python imaging library such as Pillow.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Anthropic•More Software Engineer•Anthropic Software Engineer•Anthropic Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.