code: def convert_to_png(fn_source, output_dir, sizes):
      svgs = list(versions)
      svgs.insert(0, "")
  
      cmd = "rsvg-convert"
      p = subprocess.Popen(
          cmd,
          shell=True,
          stdin=subprocess.PIPE,
          stdout=subprocess.PIPE,
          stderr=subprocess.STDOUT,
      )
      p.communicate()
      if p.returncode == 127:
          logging.error("%s: command not found. Install librsvg" % cmd)
          sys.exit(p.returncode)
  
      for ver in svgs:
          if ver == "":
              fn_svg = fn_source
              if system()[0:3].lower() == "win":
                  os.chdir(default_source_dir)
          else:
              fn_svg = get_svg_filename_from_versionkey(fn_source, ver)
              fn_svg = os.path.join(output_dir, fn_svg)
              if system()[0:3].lower() == "win":
                  os.chdir(default_output_dir)
  
          basename = os.path.basename(fn_svg)
          name, ext = os.path.splitext(basename)
          for size in sizes:
              if system()[0:3].lower() == "win":
                  fn_out = "%s-%dpx.png" % (name, size)
                  fn_out = os.path.join(
                      os.pardir, os.pardir, "_build", "logo", fn_out
                  )
                  name_c = "%s.svg" % (name)
                  cmd = "rsvg-convert %s -f png -h %d -w %d > %s" % (
                      name_c,
                      size,
                      size,
                      fn_out,
                  )
              else:
                  fn_out = "%s-%dpx.png" % (name, size)
                  fn_out = os.path.join(output_dir, fn_out)
                  cmd = "rsvg-convert %s -f png -o %s -h %d -w %d" % (
                      fn_svg,
                      fn_out,
                      size,
                      size,
                  )
  
              p = subprocess.Popen(
                  cmd,
                  shell=True,
                  stdin=subprocess.PIPE,
                  stdout=subprocess.PIPE,
                  stderr=subprocess.STDOUT,
              )
              p.communicate()
              if p.returncode != 0:
                  logging.error(
                      "Return code is not 0: Command: %s" % cmd
                  )
                  logging.error("return code: %s" % p.returncode)
                  sys.exit(p.returncode)
              else:
                  logging.debug("command: %s" % cmd)
                  logging.debug("return code: %s" % p.returncode)
  
file_path: sympy/doc/generate_logos.py
imports: from argparse import ArgumentParser
  import xml.dom.minidom
  import os.path
  import logging
  import subprocess
  import sys
  from platform import system
label_desc: Use image node_id 3 for calling a global function with example usage: convert_to_png(fn_source, output_dir, sizes) without return types