Home / Library / PIL / Handbook

The PIL handbook

The handbook Fredrik Lundh wrote described PIL 1.1.7. It is not reproduced here. This page maps what was in it to where the same material lives today.

Snapshots of the original handbook are in the Internet Archive. It remains a good explanation of the model, as long as you translate the Python 2 syntax and the constants that have since moved.

The modules

ModuleWhat it doesHere
ImageOpening, saving, converting, resizing, the class everything returnsImage module
ImageDrawLines, shapes and text onto an imageImageDraw
ImageFilterBlur, sharpen, edge finding, custom kernelsImageFilter
ImageEnhanceBrightness, contrast, colour, sharpnessImageEnhance
ImageOpsAutocontrast, fit, pad, invert, exif_transposeImageOps
ImageChopsChannel arithmetic, difference, offsetPillow docs
ImageColorColour names and strings to valuesPalette tool
ImageFontBitmap and TrueType fontsSee the note on text below
ImageTkShowing images in TkinterTkinter introduction
ImagePathCompact coordinate lists for drawingImagePath
ImageFileDecoding from a stream, truncated filesImageFile
ImageSequenceFrames of an animationPillow docs
ImageStatSums, means and extrema of an imagePillow docs
ImageGrabScreen capturesPillow docs

The one that catches everybody

Handbook era code measures text like this:

w, h = draw.textsize("hello", font=font)

textsize was removed in Pillow 10. The replacement returns a box rather than a size:

left, top, right, bottom = draw.textbbox((0, 0), "hello", font=font)
w = right - left
h = bottom - top

The converter flags this, along with everything else that changed.

Start here instead