title: Convert EPS images to JPG using Pillow
body: <p>I am working on a script that will generate a succession of images drawn using the python turtle module.  In researching this I have found that I will probably be only able to get EPS images out of turtle which I have been successful in doing.  For a quick demo of this I then had to use Photoshop to batch convert the images.  I would therefore obviously like to do the conversion within the script.</p>
  
  <ol>
  <li>Draw a frame using turtle</li>
  <li>Get the frame in EPS</li>
  <li>Convert the frame to
  JPG</li>
  <li>Repeat</li>
  </ol>
  
  <p>Within the script are two functions I have tried as well as a simplified bit of conversion code within the for loop.  The first function produces an error message and the second function does nothing.  Within the simplified conversion code within the for loop I have identified the line which is causing the issue which probably has something to do with the save method.</p>
  
  <p>I am using the latest version of Pillow with Python 3.4 and have removed PIL.  Based on a response below I have also tried adding ghostscript but this isn't supported in Python 3.</p>
  
  <pre><code>#! /usr/local/bin/python3
  
  from turtle import *
  from PIL import Image #imports image class
  import random
  import os, sys
  
  title("Vine Video")
  setup(480, 480, 0, 0)
  delay(0)
  hideturtle()
  
  colormode(255)
  
  def saveImage(fileName):
      turtleImage = getscreen()
      turtleImage.getcanvas().postscript(file=fileName+".eps")
      print("File saved as ",fileName+".eps")
  
  ###Functions which haven't worked so far
  
  ##def eps2jpg(): ### Convert .eps files to .jpg - function from @trevorappleton
  ## 
  ##    openFiles = glob.glob('*.eps')
  ##    for files in openFiles:
  ## 
  ##        inFile = Image.open(files)
  ##        fileName = os.path.splitext(files)[0] # gets filename
  ##        outFile = fileName + ".jpg"
  ### Following line produces error
  ##        inFile.save(outFile)
  ## 
  ##    return()
  ##
  ##
  ##
  ##def eps2jpg2():
  ##    for infile in sys.argv[1:]:
  ##        f, e = os.path.splitext(infile)
  ##        outfile = f + ".jpg"
  ##        if infile != outfile:
  ##            try:
  ##                Image.open(infile).save(outfile)
  ##            except IOError:
  ##                print("cannot convert", infile)
  
  frames = [50,98,141,178,208,228,239]
  filenames = ["frame1","frame2","frame3","frame4","frame5","frame6","frame7"]
  
  for i in range(7):
      for j in range(150):
          randomRed = random.randint(1,254)
          randomGreen = random.randint(1,254)
          randomBlue = random.randint(1,254)
  
          randomLength = random.randint(0,frames[i])
          randomTurn = random.randint(-95,95)
  
          pencolor(randomRed,randomGreen,randomBlue)
          forward(randomLength)
          right(randomTurn)
          goto(0,0)
  
      saveImage(filenames[i])
  
  #simplified conversion code
      inFile = Image.open(filenames[i]+".eps")
      outFile = filenames[i] + ".jpg"
  #following line produces the error: no such file or directory 'gs'
      inFile.save(outFile)
  
      clear()
  
  write("done - close turtle window now")
  
  done()
  </code></pre>
  
  <p>The error message which is generated by the first function and by the simplified conversion code is as follows:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/sharland/Dropbox/computing_department/Languages and Systems/python/python_scripts/vine_animations/starburst_pulse.py", line 61, in &lt;module&gt;
      inFile.save(outFile,"JPEG")
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/Image.py", line 1631, in save
      self.load()
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/EpsImagePlugin.py", line 361, in load
      self.im = Ghostscript(self.tile, self.size, self.fp, scale)
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/EpsImagePlugin.py", line 130, in Ghostscript
      gs = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 848, in __init__
      restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1441, in _execute_child
      raise child_exception_type(errno_num, err_msg)
  FileNotFoundError: [Errno 2] No such file or directory: 'gs'
  </code></pre>