Transform images with PIL operations

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

Images · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

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
terminal
pip install pixeltable
Pixeltable calls
pxt.create_table()insert()add_computed_column()

A look at the code

img-pil-transforms.ipynb
# 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.

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103