Skip to content

Instantly share code, notes, and snippets.

View fabeat's full-sized avatar
🎯
Focusing

Fabian Graßl fabeat

🎯
Focusing
  • cadooz GmbH
  • Nürnberg
View GitHub Profile
@fabeat
fabeat / scale.py
Created September 19, 2013 10:13 — forked from enagorny/scale.py
from PIL import Image
def scale(image, max_size, method=Image.ANTIALIAS):
"""
resize 'image' to 'max_size' keeping the aspect ratio
and place it in center of white 'max_size' image
"""
im_aspect = float(image.size[0])/float(image.size[1])
out_aspect = float(max_size[0])/float(max_size[1])
if im_aspect >= out_aspect: