Last active
June 13, 2018 04:19
-
-
Save omsobliga/f3f8643e733f97d13d3f0a57a7325de4 to your computer and use it in GitHub Desktop.
保存图片到buffer
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
### 保存图片到内存 | |
import StringIO | |
output = StringIO.StringIO() | |
format = 'PNG' # or 'JPEG' or whatever you want | |
image.save(output, format) | |
contents = output.getvalue() | |
output.close() | |
### 保存图片到文件 | |
file = 'image.png' | |
image.save(file_name) | |
with open(file_name) as f: | |
image = StringIO.StringIO(f.read()) | |
upload_image(image, file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment