# utils.py
#
# author: deng
# date: 20251128

import base64
import tomllib

import streamlit as st


@st.cache_data
def convert_image_to_base64(image_path: str) -> str:
    with open(image_path, 'rb') as f:
        return base64.b64encode(f.read()).decode()


def parse_config(config_path: str) -> dict:
    """Config parser

    Args:
        config_path (str): path of config toml.

    Returns:
        dict: configuration dictionary
    """
    with open(config_path, 'rb') as file:
        config = tomllib.load(file)
    return config
