          else:
              with open(filename, "rb") as infile:
                  raw_file = infile.read()
                  metadata = png_read_meta(raw_file)
              image = cv2.imdecode(np.frombuffer(raw_file, dtype="uint8"), cv2.IMREAD_UNCHANGED)
              retval = (image, metadata)
      except TypeError as err:
          success = False
          msg = "Error while reading image (TypeError): '{}'".format(filename)
          msg += ". Original error message: {}".format(str(err))
          logger.error(msg)
 
</s> remove         if not with_metadata:
            retval = cv2.imread(filename)
            if retval is None:
 </s> add         with open(filename, "rb") as infile:
            raw_file = infile.read()
            image = cv2.imdecode(np.frombuffer(raw_file, dtype="uint8"), cv2.IMREAD_UNCHANGED)
            if image is None: </s> remove         else:
            with open(filename, "rb") as infile:
                raw_file = infile.read()
 </s> add             if with_metadata:
                retval = (image, metadata)
            else:
                retval = image
          else:
              with open(filename, "rb") as infile:
                  raw_file = infile.read()
                  metadata = png_read_meta(raw_file)
                retval = (image, metadata)
            else:
                retval = image
                retval = (image, metadata)
            else:
                retval = image
      except TypeError as err:
          success = False
          msg = "Error while reading image (TypeError): '{}'".format(filename)
          msg += ". Original error message: {}".format(str(err))
          logger.error(msg)
keep keep keep keep replace replace keep keep keep keep keep
 bugfix: error loading images with special chars 
lib/image.py