code: def load_image_file(filename):
      try:
          image_pil = PIL.Image.open(filename)
      except IOError:
          logging.error(
              "Failed opening image file: {}".format(filename)
          )
          return
  
      # apply orientation to image according to exif
      image_pil = apply_exif_orientation(image_pil)
  
      with io.BytesIO() as f:
          ext = osp.splitext(filename)[1].lower()
          if PY2 and QT4:
              format = "PNG"
          elif ext in [".jpg", ".jpeg"]:
              format = "JPEG"
          else:
              format = "PNG"
          image_pil.save(f, format=format)
          f.seek(0)
          return f.read()
  
imports: import argparse
  import collections
  import datetime
  import glob
  import json
  import os
  import os.path
  import sys
  import uuid
  import PIL
  import io
  import base64
  import logging
  import math
  import imgviz
  import numpy
label_desc: Use image node_id 2 for calling the LabelFile obj's underlying member method code with example usage: obj.load_image_file(filename) and returns: f