Skip to content

Commit

Permalink
fix(remove_transparent): remove strict string check to support pathli…
Browse files Browse the repository at this point in the history
…b objects in remove_transparent function

- Removed the check that restricted input to only strings, allowing pathlib objects as valid input
- Ensured proper handling of numpy arrays and paths, improving the function's flexibility
  • Loading branch information
alexey-krasnov committed Aug 12, 2024
1 parent 403f41f commit 4a1c71b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions DECIMER/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@ def handle_numpy_array(array: np.ndarray) -> Image.Image:
png = Image.fromarray(array).convert("RGBA")
return process_image(png)

if isinstance(image, str):
return handle_image_path(image_path=image)
elif isinstance(image, np.ndarray):
# Check if input is a numpy array
if isinstance(image, np.ndarray):
return handle_numpy_array(array=image)
else:
raise ValueError("Input should be either a string (image path) or a numpy array.")

return handle_image_path(image_path=image)


def get_bnw_image(image):
Expand Down

0 comments on commit 4a1c71b

Please sign in to comment.