A transformation pipeline is an ordered list of steps. Apply them to one image.
def apply_transformations(image, transformations: List[dict]) -> Image.Image
Each step is a dict with a type and sometimes a parameter. Use exactly these Pillow calls:
| type | call | | --- | --- | | grayscale | ImageOps.grayscale(image) | | flip_horizontal | ImageOps.mirror(image) | | flip_vertical | ImageOps.flip(image) | | scale | ImageOps.scale(image, factor) | | blur | image.filter(ImageFilter.BoxBlur(radius)) | | rotate | image.rotate(angle) — Pillow defaults, so expand=False |
Rules:
- Steps run in order; each one consumes the previous one's output.
- The image you are handed must not be modified — start from a copy.
- An empty list returns an independent copy of the input.
- An unknown
type raises ValueError.
# a 2x2 greyscale image holding 10 20
# 30 40
apply_transformations(img, [{"type": "flip_horizontal"}]) # 20 10 / 40 30
apply_transformations(img, [{"type": "rotate", "angle": 90}]) # 20 40 / 10 30