Pillow

Image loading, resizing and format conversion.

Pillow is taught here in 11 lessons, running from Opening, inspecting and saving images through to Debugging Pillow: mode errors, bombs and truncated files. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.

TrackPython & Data Science
Lessons11
LevelBeginner to intermediate
Reading timeabout 2 hours
PrerequisitesHelpful, but not required: SciPy

Lessons

  1. Opening, inspecting and saving imagesWhat Image.open actually does, how to read a file's real properties, and how to save in a format that supports the modes you have.
  2. Resizing, cropping and rotatingThe geometry operations, which resampling filter to pick, and why rotate and thumbnail have surprising defaults.
  3. Drawing and converting formatsAnnotating images with ImageDraw, compositing with alpha, and converting safely between pixel modes in a batch.
  4. Installing Pillow and the format matrixInstall a build with the codecs you actually need, and query Pillow at runtime to see which formats it can read and write.
  5. Bands, channels and colour modes in depthInspect and manipulate individual channels, convert between modes deliberately, and understand what a palette image really stores.
  6. Filters and enhancementBlur, sharpen and detect edges with ImageFilter, tune brightness and contrast with ImageEnhance, and understand what each operation costs.
  7. ImageOps: autocontrast, pad, fit and montageNormalise exposure, place an image in an exact canvas, crop avatars to squares, and build contact sheets without writing geometry by hand.
  8. Reading and writing EXIF and image metadataRead orientation, camera data and GPS, apply the orientation tag correctly, and strip metadata before publishing files.
  9. Animated images: GIF and WebP framesIterate frames of an animation, assemble your own, control duration and looping, and work around the palette limits of GIF.
  10. Batch image processing scripts and performanceProcess a directory of images correctly, decode faster with draft and reduce, and use processes rather than threads for CPU-bound work.
  11. Debugging Pillow: mode errors, bombs and truncated filesDiagnose the exceptions Pillow actually raises, disable the decompression-bomb guard deliberately, and handle damaged files without crashing a batch.

More in Python & Data Science

Python 3 NumPy pandas Matplotlib Jupyter Notebook Flask FastAPI Django SciPy Python 2.x R Julia

FAQ

How long does the Pillow course take?
It has 11 lessons, about 2 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Pillow?
Not strictly. It helps to have read SciPy first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Pillow?
Continue with Python 2.x (11 lessons), the next course in Python & Data Science.