This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |