411 REFERENCE · Wikibooks
Python Imaging Library/File IO
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
File operations in PIL are very simple, and reflect normal Python methods.
open
import Image
img = Image.open(filepath)
load
from PIL import Image
img = Image.open("path/to/image.ext")
pixels = img.load() # Load the pixels of the image into a matrix
show
Displays a copy of the specified image in a window.from PIL import Image
img = Image.open("path/to/image.ext")
img.show() # Shows the image in a new window
save
import Image
img = Image.open(filepath)
img.save("example.png")
#img.save(outfile, options...)
#img.save(outfile, format, options...)