Skip to content

Instantly share code, notes, and snippets.

View sushantsp's full-sized avatar
🎯
Focusing

Sushant sushantsp

🎯
Focusing
  • Senior DS, Reliaquest | Manager, DS Pfizer | Ex-Cipla | Ex-General Motors
  • Pune
View GitHub Profile
@sushantsp
sushantsp / crop_and_resize.py
Created December 16, 2017 17:35 — forked from mattjmorrison/crop_and_resize.py
Resize and Crop images with Python and PIL
from PIL import Image, ImageChops
def trim(im, border):
bg = Image.new(im.mode, im.size, border)
diff = ImageChops.difference(im, bg)
bbox = diff.getbbox()
if bbox:
return im.crop(bbox)
def create_thumbnail(path, size):