def _save(im, fp, filename, eps=1):
 im.load()
 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')
 class NoCloseStream(object, ):
  def __init__(self, fp):
   self.fp = fp
  def __getattr__(self, name):
   return getattr(self.fp, name)
  def close(self):
   pass
 base_fp = fp
 if (fp != sys.stdout):
  fp = NoCloseStream(fp)
  if (sys.version_info[0] > 2):
   fp = io.TextIOWrapper(fp, encoding='latin-1')
 if eps:
  fp.write('%!PS-Adobe-3.0 EPSF-3.0\n')
  fp.write('%%Creator: PIL 0.1 EpsEncode\n')
  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))
 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))
 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()

def _save ( im , fp , filename , eps = 1 ) : im . load ( ) 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' ) class NoCloseStream ( object , ) : def __init__ ( self , fp ) : self . fp = fp def __getattr__ ( self , name ) : return getattr ( self . fp , name ) def close ( self ) : pass base_fp = fp if ( fp != sys . stdout ) : fp = NoCloseStream ( fp ) if ( sys . version_info [ 0 ] > 2 ) : fp = io . TextIOWrapper ( fp , encoding = 'latin-1' ) if eps : fp . write ( '%!PS-Adobe-3.0 EPSF-3.0\n' ) fp . write ( '%%Creator: PIL 0.1 EpsEncode\n' ) 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 ) ) 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 ) ) 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 ( )
method decorator that saves data to attribute .