Created
June 22, 2015 16:25
-
-
Save d7my11/f6ec354f5acabe3ea243 to your computer and use it in GitHub Desktop.
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 | |
if self.thumbnail: | |
try: | |
image = Image.open(self.thumbnail.path) | |
(width, height) = image.size | |
"Max width and height 800" | |
if (700 / width < 471 / height): | |
factor = 471 / height | |
else: | |
factor = 700 / width | |
size = (width / factor, height / factor) | |
image = image.resize(size, Image.ANTIALIAS) | |
image.save(self.thumbnail.path) | |
except Exception: | |
# TODO log | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment