sygslhy / image-io

Image io python APIs to wrap cxx_image C++ lib by using pybind11
MIT License
6 stars 2 forks source link

read_image does not work with pathlib.Path #2

Closed emmcb closed 1 month ago

emmcb commented 1 month ago

Currently calling read_image(path) with path a pathlib.Path objects fails with the following error:

Traceback (most recent call last):
  File "/home/emmanuel/.local/lib/python3.12/site-packages/cxx_image_io/io.py", line 49, in read_image
    metadata = parser.readMetadata(image_path, metadata_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: readMetadata(): incompatible function arguments. The following argument types are supported:
    1. (arg0: str, arg1: Optional[str]) -> Optional[cxx_image.ImageMetadata]

Invoked with: _PosixPath('...'), None

read_image(str(path)) works as a workaround, but it should probably be better if Path were directly supported.

sygslhy commented 1 month ago

Please try it with new v0.0.10, I changed it to patlib.Path

https://pypi.org/project/cxx-image-io/0.0.10/

emmcb commented 1 month ago

Thanks it works fine!