code: def _imload(self, filepath, kwds):
          start_time = time.time()
          typ, enc = mimetypes.guess_type(filepath)
          if not typ:
              typ = 'image/jpeg'
          typ, subtyp = typ.split('/')
          self.logger.debug("MIME type is %s/%s" % (typ, subtyp))
          data_loaded = False
          if have_opencv and subtyp not in ['gif']:
              means = 'opencv'
              data_np = cv2.imread(filepath,
                                   cv2.IMREAD_ANYDEPTH + cv2.IMREAD_ANYCOLOR)
              if data_np is not None:
                  data_loaded = True
                  if len(data_np.shape) >= 3 and data_np.shape[2] >= 3:
                      data_np = data_np[..., :: -1]
                  self.piexif_getexif(filepath, kwds)
                  kwds['Orientation'] = 1
                  kwds['Image Orientation'] = 1
                  if self.clr_mgr.can_profile():
                      data_np = self.clr_mgr.profile_to_working_numpy(data_np, kwds)
          if not data_loaded and have_pil:
              means = 'PIL'
              image = PILimage.open(filepath)
              try:
                  if hasattr(image, '_getexif'):
                      info = image._getexif()
                      if info is not None:
                          for tag, value in info.items():
                              kwd = TAGS.get(tag, tag)
                              kwds[kwd] = value
                  elif have_exif:
                      self.piexif_getexif(image.info["exif"], kwds)
                  else:
                      self.logger.warning("Please install 'piexif' module to get image metadata")
              except Exception as e:
                  self.logger.warning("Failed to get image metadata: %s" % (str(e)))
              if self.clr_mgr.can_profile():
                  image = self.clr_mgr.profile_to_working_pil(image, kwds)
              data_np = np.array(image)
              if data_np is not None:
                  data_loaded = True
          if (not data_loaded and (typ == 'image') and
              (subtyp in ('x-portable-pixmap', 'x-portable-greymap'))):
              means = 'built-in'
              data_np = open_ppm(filepath)
              if data_np is not None:
                  data_loaded = True
          if not data_loaded:
              raise ImageError("No way to load image format '%s/%s'" % (
                  typ, subtyp))
          end_time = time.time()
          self.logger.debug("loading (%s) time %.4f sec" % (
              means, end_time - start_time))
          return data_np