class - pil (Image)

Python Imaging Library (PIL)

* there are no modules in the standard library for reading/writing/processing images directly.

import Image

#
Image.open(f)

# Creates a new image with the given mode and size.
Image.new(mode,size,color=None)

# resize
im.resize(size)

# rotate (angle)

# save
im.save(outfile, options…)

# show()
On Windows, it saves the image to a temporary BMP file,
 and uses the standard BMP display utility to show it.

Attributes

.mode
.format    GIF ...
.size      (w, h)     # pixels
.info

Modes
"1"    1    Black and white
"L"    1    Gray scale

"RGB"    3    True red-green-blue color, three bytes per pixel.
"RGBA"    4    True color with a transparency band
"CMYK"    4    Cyan-magenta-yellow-black color,

Example:

from PIL import Image
im = Image.open("bride.jpg")
im.rotate(45).show()

Creative Commons license icon Creative Commons license icon