Crop images using Python PIL - Pillow
examples/python/crop_image.py
from PIL import Image from PIL import ImageFont from PIL import ImageDraw import sys in_file = 'in.png' out_file = 'out.png' img = Image.open(in_file) width, height = img.size # crop # 10 pixels from the left # 20 pixels from the top # 30 pixels from the right # 40 pixels from the bottom cropped = img.crop((10, 20, width-30, height-40)) cropped.save(out_file)
Published on 2019-04-22
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post