Created
December 25, 2014 03:11
-
-
Save taojy123/13372a41d2ed08005955 to your computer and use it in GitHub Desktop.
利用StringIO存取图片
This file contains hidden or 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 | |
import StringIO | |
s = open("1.jpg", "rb").read() | |
im = Image.open(StringIO.StringIO(s)) | |
im.save("2.jpg", "jpeg") | |
sio = StringIO.StringIO() | |
im.save(sio, "jpeg") | |
sio.seek(0) | |
open("3.jpg", "wb").write(sio.read()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment