Skip to content

Commit

Permalink
bugfix: error loading images with special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Aug 27, 2023
1 parent cf0efff commit 5d00025
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,16 @@ def read_image(filename, raise_error=False, with_metadata=False):
success = True
image = None
try:
if not with_metadata:
retval = cv2.imread(filename)
if retval is None:
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:
raise ValueError("Image is None")
else:
with open(filename, "rb") as infile:
raw_file = infile.read()
if with_metadata:
metadata = png_read_meta(raw_file)
image = cv2.imdecode(np.frombuffer(raw_file, dtype="uint8"), cv2.IMREAD_UNCHANGED)
retval = (image, metadata)
retval = (image, metadata)
else:
retval = image
except TypeError as err:
success = False
msg = "Error while reading image (TypeError): '{}'".format(filename)
Expand Down

0 comments on commit 5d00025

Please sign in to comment.