Created
October 16, 2015 08:20
-
-
Save guyoun/26936b4aea817c18c4ca to your computer and use it in GitHub Desktop.
resize image using pillow
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
img_io = cStringIO.StringIO() | |
app = current_app._get_current_object() | |
try: | |
#pil_img.thumbnail(tuple(size), Image.ANTIALIAS) | |
#pil_img.save(img_io, 'PNG') | |
#img_io.seek(0) | |
resized_img = pil_img.resize(tuple(size), Image.ANTIALIAS) | |
resized_img.save(img_io, 'PNG') | |
img_io.seek(0) | |
return img_io | |
except Exception as e: | |
app.logger.info("thumbnail> %r" % e) | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment