Skip to content

Instantly share code, notes, and snippets.

@guyoun
Created October 16, 2015 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyoun/26936b4aea817c18c4ca to your computer and use it in GitHub Desktop.
Save guyoun/26936b4aea817c18c4ca to your computer and use it in GitHub Desktop.
resize image using pillow
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