pil crop image python code example
Example 1: pillow python crop
im = Image.open('image.jpg')
im = im.crop((left, top, width, height))
# ├─input image width─┤
# ┬ ┌───────────────────┐ ┬ ┬
# │ │ │top │
# input │ ┌───────┐ │ ┴ height
# image │ │ │ │ │
# height│ └───────┘ │ ┴
# │ │ │
# ┴ └───────────────────┘
# ├─left─┤
# ├─────width─────┤
Example 2: pil crop image
im = Image.open('image.jpg')
im = im.crop((left, top, right, bottom)) # coordinates of the crop