def _hex_to_rgb(_hex):
    """ Convert hex color code to RGB tuple
    Args:
        hex (str): Hex color string, e.g '#ff12ff' or 'ff12ff'
    Returns:
        (rgb): tuple i.e (123, 200, 155) or None
    """
    try:
        if '#' in _hex:
            _hex = _hex.replace('#', "").strip()
        if len(_hex) != 6:
            return None
        (r, g, b) = int(_hex[0:2], 16), int(_hex[2:4], 16), int(_hex[4:6], 16)
        return (r, g, b)
    except Exception:
        return None