What I'm trying to do here is save the contents of Tkinter Canvas as a .png image using PIL.
This is my save function ('graph' is a canvas).
def SaveAs(): filename = tkFileDialog.asksaveasfilename(initialfile="Untitled Graph", parent=master) graph.postscript(file=filename+".eps") img = Image.open(filename+".eps") img.save(filename+".png", "png")
But he gets this error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__ return self.func(*args) File "C:\Users\Adam\Desktop\Graphing Calculator\Graphing Calculator.py", line 352, in SaveAs img.save(filename+".png", "png") File "C:\Python27\lib\site-packages\PIL\Image.py", line 1406, in save self.load() File "C:\Python27\lib\site-packages\PIL\EpsImagePlugin.py", line 283, in load self.im = Ghostscript(self.tile, self.size, self.fp) File "C:\Python27\lib\site-packages\PIL\EpsImagePlugin.py", line 72, in Ghostscript gs.write(s) IOError: [Errno 32] Broken pipe
I am running this on Windows 7, Python 2.7.1.
How do I do this job?
source share