How to install and use Python graphic processing graphics library

Source: Internet
Author: User

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

Td>l /tr>
1  1 bit pixels, black and white, save as 8 pixels
 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
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.