code: def get_base64_string_from_path(
      img_path: str, return_image_size: bool = False
  ) -> Union[str, Tuple[str, Tuple[int, int]]]:
      """Load and convert pillow image to base64-encoded image
  
      :param img_path: image path
      :type img_path: str
      :param return_image_size: true if image size should also be returned
      :type return_image_size: bool
      :return: base64-encoded image OR base64-encoded image and image size
      :rtype: Union[str, Tuple[str, Tuple[int, int]]]
      """
      try:
          img = Image.open(img_path)
      except Exception as e:
          print("file not found", str(e))
          import urllib.request
  
          urllib.request.urlretrieve(img_path, "tempfile")
          img = Image.open("tempfile")
      imgio = BytesIO()
      img.save(imgio, img.format)
      img_str = base64.b64encode(imgio.getvalue())
      if return_image_size:
          return (
              img_str.decode(CommonTags.IMAGE_DECODE_UTF_FORMAT),
              img.size,
          )
      return img_str.decode(CommonTags.IMAGE_DECODE_UTF_FORMAT)
  
file_path: responsible-ai-toolbox/responsibleai_vision/responsibleai_vision/utils/image_reader.py
imports: import base64
  from io import BytesIO
  from typing import Any, Tuple, Union
  from urllib.parse import urlparse
  import requests
  from numpy import asarray
  from PIL import Image
  from PIL.ExifTags import TAGS
  from requests.adapters import HTTPAdapter, Retry
  from responsibleai_vision.common.constants import AutoMLImagesModelIdentifier, CommonTags
label_desc: Use image node_id 5 for calling a global function with example usage: get_base64_string_from_path(img_path, return_image_size) and returns: img_str, img_str,  img