def convert_to_image_file_format(format_str):
    """Converts a legacy file format string to an ImageFileFormat enum value.

  Args:
    format_str: A string describing an image file format that was passed to
      one of the functions in ee.data that takes image file formats.

  Returns:
    A best guess at the corresponding ImageFileFormat enum name.
  """
    if format_str is None:
        return 'AUTO_JPEG_PNG'
    format_str = format_str.upper()
    if format_str == 'JPG':
        return 'JPEG'
    elif format_str == 'AUTO':
        return 'AUTO_JPEG_PNG'
    elif format_str == 'GEOTIFF':
        return 'GEO_TIFF'
    elif format_str == 'TFRECORD':
        return 'TF_RECORD_IMAGE'
    else:
        return format_str
