I have a program that generates pictures and either saves them to a file or prints out the raw image data in standard output. I am using Python subprocess module to call the external program, catch its stdout data and create a Python image object from the data. I keep getting "Cannot identify image file" error, though. I am new to this part of Python. Can you please help if you know how to achieve this? Here is my code:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
raw = p.stdout.read()
buff = StringIO.StringIO()
buff.write(raw)
buff.seek(0)
im = Image.open(buff)
im.show()