Surn commited on
Commit
f4556ed
·
1 Parent(s): d94e08e

Add try_open_image

Browse files
Files changed (1) hide show
  1. modules/image_utils.py +7 -0
modules/image_utils.py CHANGED
@@ -70,6 +70,13 @@ def get_image_from_dict(image_path):
70
  else:
71
  return image_path, False
72
 
 
 
 
 
 
 
 
73
  def open_image(image_path):
74
  """
75
  Opens an image from a file path or URL, or decodes a DataURL string into an image.
 
70
  else:
71
  return image_path, False
72
 
73
+ def try_open_image(image_path):
74
+ try:
75
+ return open_image(image_path)
76
+ except Exception as e:
77
+ print(f"Skipping image {image_path} due to error: {e}")
78
+ return None
79
+
80
  def open_image(image_path):
81
  """
82
  Opens an image from a file path or URL, or decodes a DataURL string into an image.