code: def convert_images(image_list, image_format="png", timeout=20):
      
      png_output_contains = 'PNG image'
      image_mapping = {}
      for image_file in image_list:
          if os.path.isdir(image_file):
              continue
  
          if not os.path.exists(image_file):
              continue
  
          cmd_out = check_output(['file', image_file], timeout=timeout)
          if cmd_out.find(png_output_contains) > -1:
              # Already PNG
              image_mapping[image_file] = image_file
          else:
              # we're just going to assume that ImageMagick can convert all
              # the image types that we may be faced with
              # for sure it can do EPS->PNG and JPG->PNG and PS->PNG
              # and PSTEX->PNG
              converted_image_file = get_converted_image_name(image_file)
              try:
                  convert_image(image_file, converted_image_file, image_format)
              except (MissingDelegateError, ResourceLimitError):
                  # Too bad, cannot convert image format.
                  continue
              if os.path.exists(converted_image_file):
                  image_mapping[converted_image_file] = image_file
  
      return image_mapping
docs: Convert images from list of images to given format, if needed.
  
      Figure out the types of the images that were extracted from
      the tarball and determine how to convert them into PNG.
  
      :param: image_list ([string, string, ...]): the list of image files
          extracted from the tarball in step 1
      :param: image_format (string): which image format to convert to.
          (PNG by default)
      :param: timeout (int): the timeout value on shell commands.
  
      :return: image_mapping ({new_image: original_image, ...]): The mapping of
          image files when all have been converted to PNG format.