# load library
from PIL import Image
# read image
pil_im = Image.open('cloud.jpg')
pil_im
# convert image to grayscale one
pil_im = Image.open('cloud.jpg').convert('L')
pil_im
# create thumbnail image
pil_im.thumbnail((300,300))
pil_im
# crop a region
pil_im = Image.open('cloud.jpg')
box = (200,200,500,500)
region = pil_im.crop(box)
region
# rotate this region (90 degrees)
region = region.transpose(Image.ROTATE_90)
region
# put back this region to fig
pil_im.paste(region, box)
pil_im
# resize image
pil_im = Image.open('cloud.jpg')
pil_im.resize((128,128))
# rotate image 45 degrees (counter-clockwise)
pil_im = Image.open('cloud.jpg')
pil_im = pil_im.resize((128,128))
pil_im.rotate(30)