概览

The Python Imaging Library adds image processing capabilities to yourPython interpreter.

This library provides extensive file format support, an efficient internalrepresentation, and fairly powerful image processing capabilities.

The core image library is designed for fast access to data stored in a fewbasic pixel formats. It should provide a solid foundation for a general imageprocessing tool.

Let’s look at a few possible uses of this library.

图像压缩

The Python Imaging Library is ideal for image archival and batch processingapplications. You can use the library to create thumbnails, convert betweenfile formats, print images, etc.

The current version identifies and reads a large number of formats. Writesupport is intentionally restricted to the most commonly used interchange andpresentation formats.

图像显示

The current release includes Tk PhotoImage andBitmapImage interfaces, as well as a Windows
DIB interface
that can be used with PythonWin and otherWindows-based toolkits. Many other GUI toolkits come with some kind of PILsupport.

For debugging, there’s also a show() method which saves an image todisk, and calls an external display utility.

图像处理

The library contains basic image processing functionality, including point operations, filtering with a set of built-in convolution kernels, and colour space conversions.

The library also supports image resizing, rotation and arbitrary affine transforms.

There’s a histogram method allowing you to pull some statistics out of an image. This can be used for automatic contrast enhancement, and for global statistical analysis.