LatexImage.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:OKUSON 作者: frankluebeck 项目源码 文件源码
def PnmToPng(pnmstring, reporterror = Utils.Error):
  '''Convert a pnm file into a png file by piping through "pnmtopng".
"pnmstring" can either be a string or a list of strings. Accordingly,
one png in a string or a list of pngs in strings is returned.'''
  if type(pnmstring) == types.ListType:
      res = []
      for p in pnmstring:
          res.append(PnmToPng(p,reporterror))
      return res
  if type(pnmstring) != types.StringType:
    return pnmstring
  try:
      inp,out = os.popen2('pnmtopng -compression 9 -background white '+
                          '-transparent white', bufsize=len(pnmstring)+1024)
      inp.write(pnmstring)
      inp.close()
      res = out.read()
      out.close()
  except:
      msg = 'Problems during call to "pnmtopng".'
      reporterror(msg)
      raise Utils.UtilsError, msg

  return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号