<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def render_pdf_file_to_image_files(pdf_file_name, output_filename_root, program_to_use):
 """Render all the pages of the PDF file at pdf_file_name to image files with path and filename prefix given by output_filename_root. Any directories must have already been created, and the calling program is responsible for deleting any directories or image files. The program program_to_use, currently either the string "pdftoppm" or the string "Ghostscript", will be called externally. The image type that the PDF is converted into must to be directly openable by PIL."""


    res_x = str(args.resX)
    res_y = str(args.resY)
    if program_to_use == "Ghostscript":
        if ex.system_os == "Windows": # Windows PIL is more likely to know BMP
            ex.render_pdf_file_to_image_files__ghostscript_bmp(
                                  pdf_file_name, output_filename_root, res_x, res_y)
        else: # Linux and Cygwin should be fine with PNG
            ex.render_pdf_file_to_image_files__ghostscript_png(
                                  pdf_file_name, output_filename_root, res_x, res_y)
    elif program_to_use == "pdftoppm":
        use_gray = False # this is currently hardcoded, but can be changed to use pgm
        if use_gray:
            ex.render_pdf_file_to_image_files_pdftoppm_pgm(
                pdf_file_name, output_filename_root, res_x, res_y)
        else:
            ex.render_pdf_file_to_image_files_pdftoppm_ppm(
                pdf_file_name, output_filename_root, res_x, res_y)
    else:
        print("Error in renderPdfFileToImageFile: Unrecognized external program.",
              file=sys.stderr)
        ex.cleanup_and_exit(1)