code: def convert_to_ico(fn_source, output_dir, sizes):
      # firstly prepare *.png files, which will be embedded
      # into the *.ico files.
      convert_to_png(fn_source, output_dir, sizes)
  
      svgs = list(versions)
      svgs.insert(0, "")
  
      if system()[0:3].lower() == "win":
          cmd = "magick"
      else:
          cmd = "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 imagemagick" % cmd
          )
          sys.exit(p.returncode)
  
      if system()[0:3].lower() == "win":
          os.chdir(default_output_dir)
      for ver in svgs:
          if ver == "":
              fn_svg = fn_source
          else:
              fn_svg = get_svg_filename_from_versionkey(fn_source, ver)
              fn_svg = os.path.join(output_dir, fn_svg)
          basename = os.path.basename(fn_svg)
          name, ext = os.path.splitext(basename)
  
          # calculate the list of *.png files
          pngs = []
          for size in sizes:
              fn_png = "%s-%dpx.png" % (name, size)
              if system()[0:3].lower() != "win":
                  fn_png = os.path.join(output_dir, fn_png)
              pngs.append(fn_png)
  
          # convert them to *.ico
          fn_out = "%s-favicon.ico" % name
          if system()[0:3].lower() != "win":
              fn_out = os.path.join(output_dir, fn_out)
  
          cmd = "{} {} {}".format(cmd, " ".join(pngs), fn_out)
          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 4 for calling a global function with example usage: convert_to_ico(fn_source, output_dir, sizes) without return types