PIL library use

  Image Module

A, open

Image.open(file)

Image.open(file,mode)

If the mode variable is set, it must be "r", the user can use a string (a string representing the file name), or as a file object of the file variable. File objects must implement the read (), seek () and tell () method, and the binary mode.

 Two, new

Image.new(mode,size)

Image.new(mode,size,color)

new method for using the given variable MODE (mode) and a size (dimension) to generate a new image.

1) About mode: 'RGB' refers to an RGB color image, 'L' refers to a grayscale image.

2) About color: For single-channel image, only given a variable color value; For multi-channel images, given a variable color tuple (a value per channel). You can also use the color name, such as assignment to a variable color "red". If there is no color assignment to a variable, the entire image content will be assigned to 0 (the image that is black). If the variable color is empty, images will not be initialized, that is, the content of the image of all zeros.

                                                                    Renderings                                                                    renderings

     

 

 

                   

 

Guess you like

Origin www.cnblogs.com/ni23/p/12663906.html