docs: def optimize_png_file(f, o=None):
      """
      Use pngquant for optimize PNG-image.
      f - path to input image file or file-object.
      o - path to output image file or file-object for save result.
      NOTICE: f and o can not be of different type
      """
      if isinstance(f, basestring):
          if o is None:
              o = f
          else:
              assert isinstance(o, basestring)
          try:
              subprocess.check_call(['pngquant', '--force', '--output', o, f])
          except subprocess.CalledProcessError:
              return False
          return True
      if not hasattr(f, 'read'):
          raise RuntimeError
      if o is None:
          o = f
      else:
          if not hasattr(f, 'write'):
              raise RuntimeError
      f.seek(0)
      try:
          p = subprocess.Popen(['pngquant', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
          r = p.communicate(f.read())[0]
      except IOError:
          r = None
      if r:
          truncate_file(o)
          o.write(r)
          return True
      return False