Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Last active September 15, 2015 15:09
Show Gist options
  • Save rectalogic/57b56f5dc5a31b5058a2 to your computer and use it in GitHub Desktop.
Save rectalogic/57b56f5dc5a31b5058a2 to your computer and use it in GitHub Desktop.
bounds_w = 100
bounds_h = 100
im_w, im_h = im.size
scales = (bounds_w / im_w, bounds_h / im_h)
if scale_type == "meet":
scale = min(scales)
elif scale_type == "fill":
scale = max(scales)
im = im.resize((int(im_w * scale), int(im_h * scale)), Image.ANTIALIAS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment