9951 explained code solutions for 126 technologies

python-pillowHow to crop an image

from PIL import Image, ImageDraw, ImageFont

im = Image.open('/var/www/examples/heroine.png')
im = im.crop((300, 200, 500, 800))

im.show()ctrl + c

import Pillow package modules


open given image with Pillow


path to sample image to open


crops image to a given area

300, 200

top left corner of a crop area

500, 800

bottom right corner of a crop area


displays resulting image