title: How to convert a Python tkinter canvas postscript file to an image file readable by the PIL?
body: <p>So I have created a function in my program that allows the user to save whatever he/she draws on the Turtle canvas as a Postscript file with his/her own name. However, there have been issues with some colors not appearing in the output as per the nature of Postscript files, and also, Postscript files just won't open on some other platforms. So I have decided to save the postscript file as a JPEG image since the JPEG file should be able to be opened on many platforms, can hopefully display all the colors of the canvas, and it should have a higher resolution than the postscript file. So, to do that, I have tried, using the PIL, the following in my save function:</p>
  
  <pre><code>def savefirst():
      cnv = getscreen().getcanvas() 
      global hen
      fev = cnv.postscript(file = 'InitialFile.ps', colormode = 'color')
      hen = filedialog.asksaveasfilename(defaultextension = '.jpg')
      im = Image.open(fev)
      print(im)
      im.save(hen + '.jpg')
  </code></pre>
  
  <p>However, whenever I run this, I get this error:</p>
  
  <pre><code>line 2391, in savefirst
      im = Image.open(fev)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/Image.py", line 2263, in open
      fp = io.BytesIO(fp.read())
  AttributeError: 'str' object has no attribute 'read'
  </code></pre>
  
  <p>Apparently it cannot read the postscript file since it's <strong>not</strong>, according to what I know, an image in itself, so it has to first be converted into an image, THEN read as an image, and then finally converted and saved as a JPEG file. <strong>The question is, how would I be able to first <em>convert the postscript file</em> to an <em>image file</em> INSIDE the program possibly using the Python Imaging Library?</strong> Looking around SO and Google has been no help, so any help from the SO users is greatly appreciated!</p>
  
  <p><strong>EDIT:</strong> Following <code>unubuntu's</code> advice, I have now have this for my save function:</p>
  
  <pre><code>def savefirst():
      cnv = getscreen().getcanvas() 
      global hen
      ps = cnv.postscript(colormode = 'color')
      hen = filedialog.asksaveasfilename(defaultextension = '.jpg')
      im = Image.open(io.BytesIO(ps.encode('utf-8')))
      im.save(hen + '.jpg')
  </code></pre>
  
  <p>However, now whenever I run that, I get this error:</p>
  
  <pre><code>line 2395, in savefirst
      im.save(hen + '.jpg')
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/Image.py", line 1646, in save
      self.load()
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/EpsImagePlugin.py", line 337, in load
      self.im = Ghostscript(self.tile, self.size, self.fp, scale)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PIL/EpsImagePlugin.py", line 143, in Ghostscript
      stdout=subprocess.PIPE)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 950, in __init__
      restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1544, in _execute_child
      raise child_exception_type(errno_num, err_msg)
  FileNotFoundError: [Errno 2] No such file or directory: 'gs'
  </code></pre>
  
  <p><strong>What is <code>'gs'</code> and why am I getting this error now?</strong></p>