import base64


def fig2inlinehtml(fig):
    """
    small hack to convert image data to image string for html display
    Parameters
    ----------
    fig: image to be converted

    Returns
    -------
    imgestr: image in string format
    """
    figfile = fig.data
    # for python 3.x:
    figdata_png = base64.b64encode(figfile).decode()
    imgstr = '<img src="data:image/png;base64,{}" />'.format(figdata_png)
    return imgstr