Pillow library Image provides support for creating and manipulating images.
`Image typically include the following import
from PIL import Image
Image.open( n ): returns an
Imagerepresentation of the image file named by
nis the name of a local file.
Image.new( m, size, color='black' )returns a mode
mnew image, whose dimensions are
size. The background of the image
coloris optional with a default value of black.
- The mode is the representation to be used for the pixels in the image. Typically, we will use an RGB ('RGB') pixel color representation. Other common representations are RGBA, HSV, CMYK, I and F.
- An image size is specified as a two-tuple
hare respctively the desired width and height. A two-tuple is often referred to as an ordered-pair.
im is an
spot is a two-tuple
(x, y) representing an image coordinate of interest, and
c is a pixel (color).
im.widthis the width of of image
im.heightis the height of of image
im.sizeis a two-tuple giving the width and height of image
For example, the first two statements in following code segment initialize respectively
hto the width and height of image
im. The third statement initializes respectively
shalso to the width and height of image
w = im.width
h = im.height
sw, sh = im.size
im.getpixel( spot ): returns the value of the pixel at coordinate
im.putpixel( spot, c ): sets the pixel at coordinate
im.copy( ): returns a new
im.show( ): popups a copy of
im.save( n, format=None ): saves image
imto local file
nwhere the picture file type is specified by
None. If the
formatparameter is omitted or
None, the file type is given the filename extension of