http://www.pythonware.com/products/pil/
This is called the Python image Library.
Simple to open a picture
im = Image.open (' filename ')
Detailed use
Types of pictures that PIL can handle
PIL can process raster pictures (blocks of pixel data).
Channel
A picture can contain one or more data channels, and if the channels have the same dimensions and depth, PIL allows these channels to be superimposed
Mode
1 |
1 bit pixels, black and white, save as 8 pixels |
Td>l
8 bit pixels, black and white |
P |
8 bit pixels, using a palette to map to any other mode |
RGB |
3x8 pixel, True color |
RGBA |
4x8 bit pixel, true color + transparent channel | /tr>
CMYK |
4x8 bit pixels, color isolation |
YCbCr |
3x8 bit pixels, color view Frequency format |
I |
32 bit integer pixel |
F |
32 bit floating-point pixel |
|
|
Size
By the Size property of the Picture object, you can get the picture's dimensions, which is a two-tuple containing the number of pixels in both the horizontal and vertical directions.
Coordinate
PIL takes the upper left corner as the coordinate system (0,0)
Palette
Mode ("P") defines a specific color value for each pixel
Picture information
You can read additional information about a picture by using the Info property, which is related to the format of the picture.
Filter
Multiple input pixels may be mapped to a single output pixel in a geometric operation on a picture, and PIL provides 4 different sample filters (in the current release, subsequent versions may support more)
Nearest |
Recent |
Bilinear |
Double Line Style |
Bicubic |
Double three times interpolation |
AntiAlias |
Smooth |
in RGB mode, each picture is superimposed by three channels, each mode is a grayscale map, when there is a palette to color, the superposition of these three gray scale can be synthesized 3*8 bit (each pixel) of a true color picture. In the PIL library, the pattern (mode) between pictures can be transformed. Here are some simple examples, all the pictures in the example from the official website of National Geographic, in order to make the document relatively short, each picture is scaled to 1/2 size with PIL, if there is suspicion of infringement, please contact as soon as possible, I will delete these pictures.
All picture operations must have an Action object, PIL provides
open (filename) for this procedure