---
title: "Transform images with PIL operations"
description: "You need to resize, rotate, crop, or convert hundreds of images—and keep track of all the transformed versions."
url: "https://www.pixeltable.com/notebooks/img-pil-transforms"
updated: "2026-04-10"
---

# Transform images with PIL operations

You need to resize, rotate, crop, or convert hundreds of images—and keep track of all the transformed versions.

- **Type:** Notebook
- **Group:** Images

## How it works

You apply PIL transformations (resize, rotate, flip, crop) to images in your table using Pixeltable's built-in image functions—common operations that work directly on image columns.

You can iterate on transformations before adding them to your table. Use .select() with .collect() to preview results on sample images—nothing is stored in your table. If you want to collect only the first few rows, use .head(n) instead of .collect(). Once you're satisfied, use .add_computed_column() to apply the transformation to all images in your table.

## What it covers

- Basic image operations (resize, rotate, flip, crop)
- Track image properties
- Iterate on transformations before adding to your table

## What it uses

- **Install:** `pip install pixeltable`
- **Pixeltable calls:** `pxt.create_table()`, `insert()`, `add_computed_column()`

## A look at the code

```python
# Save as computed columns
t.add_computed_column(height=t.image.height)
t.add_computed_column(width=t.image.width)
t.add_computed_column(mode=t.image.mode)  # RGB, RGBA, L (grayscale), etc.
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/images/img-pil-transforms.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/images/img-pil-transforms
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/images/img-pil-transforms.ipynb
