code: def open_img(
      fn,
      gray=False,
      ignore_exif: bool = False,
      ensure_no_data_convert: bool = False,
  ) -> Union[PIL.Image.Image, np.ndarray]:
      """
      Open an image from disk `fn`.
      TIFF/TIF: A numpy array with shape (h,w) for grayscale or (h,w,c) for multi bands is returned.
      Other formats: A PIL image is returned.
      """
      if is_tif_extension(fn):
          with rasterio.open(str(fn), "r") as img:
              raw_data = img.read()
              image = chw_to_hwc(raw_data)
              if gray or image.shape[2] == 1:
                  image = image[..., 0]
      else:
          color = "L" if gray else "RGB"
  
          image = PIL.Image.open(str(fn))
  
          if not ignore_exif:
              image = PIL.ImageOps.exif_transpose(image)
  
          if not ensure_no_data_convert:
              image = image.convert(color)
  
      return image
  
file_path: icevision/icevision/utils/imageio.py
imports: from icevision.imports import *
  from PIL import ExifTags
label_desc: Use image node_id 4 for calling a global function with example usage: open_img(fn, gray, ignore_exif, ensure_no_data_convert) and returns: image