I have a png picture, and i need to save it as string, and then open it again with PIL. I’m trying to do it like that:
output = StringIO.StringIO()
old_image.save(output, format="PNG")
contents = output.getvalue()
output.close()
new_image = Image.fromstring(contents, "RGBA", old_image.size)
but it gives me an error: TypeError: 'argument 1 must be string without null bytes, not str'
How to solve this problem?
You’ve got the arguments reversed:
so
But note that it’s much easier to read from the
StringIOobject directly: