code: def _save(im, fp, filename, eps=1):
      """EPS Writer for the Python Imaging Library."""
  
      #
      # make sure image data is available
      im.load()
  
      #
      # determine postscript image mode
      if im.mode == "L":
          operator = (8, 1, "image")
      elif im.mode == "RGB":
          operator = (8, 3, "false 3 colorimage")
      elif im.mode == "CMYK":
          operator = (8, 4, "false 4 colorimage")
      else:
          raise ValueError("image mode is not supported")
  
      base_fp = fp
      wrapped_fp = False
      if fp != sys.stdout:
          if sys.version_info.major > 2:
              fp = io.TextIOWrapper(fp, encoding="latin-1")
              wrapped_fp = True
  
      try:
          if eps:
              #
              # write EPS header
              fp.write("%!PS-Adobe-3.0 EPSF-3.0\n")
              fp.write("%%Creator: PIL 0.1 EpsEncode\n")
              # fp.write("%%CreationDate: %s"...)
              fp.write("%%%%BoundingBox: 0 0 %d %d\n" % im.size)
              fp.write("%%Pages: 1\n")
              fp.write("%%EndComments\n")
              fp.write("%%Page: 1 1\n")
              fp.write("%%ImageData: %d %d " % im.size)
              fp.write('%d %d 0 1 1 "%s"\n' % operator)
  
          #
          # image header
          fp.write("gsave\n")
          fp.write("10 dict begin\n")
          fp.write("/buf %d string def\n" % (im.size[0] * operator[1]))
          fp.write("%d %d scale\n" % im.size)
          fp.write("%d %d 8\n" % im.size)  # <= bits
          fp.write(
              "[%d 0 0 -%d 0 %d]\n"
              % (im.size[0], im.size[1], im.size[1])
          )
          fp.write("{ currentfile buf readhexstring pop } bind\n")
          fp.write(operator[2] + "\n")
          if hasattr(fp, "flush"):
              fp.flush()
  
          ImageFile._save(
              im, base_fp, [("eps", (0, 0) + im.size, 0, None)]
          )
  
          fp.write("\n%%%%EndBinary\n")
          fp.write("grestore end\n")
          if hasattr(fp, "flush"):
              fp.flush()
      finally:
          if wrapped_fp:
              fp.detach()
  
imports: import io
  import os
  import re
  import sys
  from .None import Image, ImageFile
  from ._binary import i32le
label_desc: Use image node_id 4 for calling a global function with example usage: _save(im, fp, filename, eps) without return types