Booritas / slideio

BSD 3-Clause "New" or "Revised" License
49 stars 2 forks source link

Can't open file if non-ASCII characters present in filename or it's path #14

Closed IvanKosik closed 1 year ago

IvanKosik commented 1 year ago

If filename or it's path contains non-ASCII characters (tested with cyrillic), then an error occurs:

File "...\slideio-tester.py", line 6, in main
  slide = slideio.open_slide(r'D:\Temp\Выявы\107_F2.ndpi', 'NDPI')
File "...\lib\site-packages\slideio\py_slideio.py", line 233, in open_slide
  slide = Slide(path, driver)
File "...\lib\site-packages\slideio\py_slideio.py", line 168, in __init__
  self.slide = sld.open_slide(path, driver)
RuntimeError: D:\a\slideio\slideio\src\slideio\drivers\ndpi\ndpislide.cpp:86:NDPIImageDriver: File does not exist:D:\Temp\Выявы\107_F2.ndpi

Tested with 'NDPI' and 'SVS' drivers.

Windows 10, x64 Python 3.10.10 SlideIO 2.0.5 (installed via pip)

P.S.: Many thanks for the added *.ndpi support. It was very timely!

Booritas commented 1 year ago

Thank you for your message! Indeed, I did not pay attention to the string encoding. I will try to fix it ASAP! Best regards, Stanislav

Booritas commented 1 year ago

Hello, I just published a new version (2.0.6) which should solve the problem. Please let me know if you have any problem with the library or have any request for the future development. If you like the library, please consider giving a star to the repository. Best regards, Stanislav

IvanKosik commented 1 year ago

Thank you very much for the fast fix! Version 2.0.6 works great with the 'SVS' driver, even if path contains non-ASCII characters.

There is some problem with 'NDPI' driver. Now it can get slide information, but when _scene.readblock is called, an error occurs: RuntimeError: D:\a\slideio\slideio\src\slideio\drivers\ndpi\ndpiscene.cpp:26:NDPI Image Driver: Cannot open file D:\Temp\Выявы\107_F2.ndpi

Full test code:

import slideio

slide = slideio.open_slide(r'D:\Temp\Выявы\107_F2.ndpi', 'NDPI')
scene = slide.get_scene(0)
full_resolution_width = scene.rect[2]
print('full_resolution_width:', full_resolution_width)  # Print correct width
region = scene.read_block(size=(round(full_resolution_width / 8), 0))  # The error is here
print('region:', region.shape)

Full output of the test script:

full_resolution_width: 125440
Traceback (most recent call last):
  File "...\slideio-tester.py", line 7, in <module>
    region = scene.read_block(size=(round(full_resolution_width / 8), 0))  # The error is here
  File "...\lib\site-packages\slideio\py_slideio.py", line 146, in read_block
    return self.scene.read_block(rect, size, channel_indices, slices, frames)
RuntimeError: D:\a\slideio\slideio\src\slideio\drivers\ndpi\ndpiscene.cpp:26:NDPI Image Driver: Cannot open file D:\Temp\Выявы\107_F2.ndpi
Booritas commented 1 year ago

Thanks a lot for the message. I just published a fix (version 2.0.7). Let me know if it works for you. Best regards, Stanislav

IvanKosik commented 1 year ago

Thank you very much for the new version 2.0.7! It works great with non-ASCII characters in file path (tested with 'SVS' and 'NDPI' drivers).