import base64


def convert_img_to_b64_string(img_path):
    """ Converts medical image to b64 string
    This function takes the image filepath as an input and outputs it as a b64
    string. This string can be sent to the server and then the database.
    Args:
        img_path (str): the name of the file path containing an image to be
        loaded
    Returns:
        b64_img_string (str): the image file as a b64 string
    """
    with open(img_path, "rb") as image_file:
        b64_bytes = base64.b64encode(image_file.read())
    b64_img_string = str(b64_bytes, encoding='utf-8')
    return b64_img_string