tags:

views:

42

answers:

1

Is it possible to save images as string, and then I load it up to Image?

+4  A: 

You can save it to a StringIO buffer:

import pylab, numpy
from StringIO import StringIO
from PIL import Image

# plot a histogram
pylab.hist(numpy.random.rand(100))

buf = StringIO()
pylab.savefig(buf, format='png')

buf.seek(0)
im = Image.open(buf)
im.show()
ars