Skip to content

Instantly share code, notes, and snippets.

@taojy123
Created December 25, 2014 03:11
Show Gist options
  • Save taojy123/13372a41d2ed08005955 to your computer and use it in GitHub Desktop.
Save taojy123/13372a41d2ed08005955 to your computer and use it in GitHub Desktop.
利用StringIO存取图片
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