You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve error message when reading an EXR file without plugin installed #334
It's just a minor thing, but if the EXR plugin is not installed, EXR images cannot be read and imageio.imread fails with this error message:
>>> img = imageio.imread(path)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\remib\.virtualenvs\qzMurbXh\lib\site-packages\imageio\core\functions.py", line 206, in imread
reader = read(uri, format, 'i', **kwargs)
File "C:\Users\remib\.virtualenvs\qzMurbXh\lib\site-packages\imageio\core\functions.py", line 126, in get_reader
'in mode %r' % mode)
ValueError: Could not find a format to read the specified file in mode 'i'
All that is required to fix this is to run
imageio.plugins.freeimage.download()
Maybe this call should be mentioned in the error message ?
That would be much better indeed. Would not be trivial to add though. When the format manager iterates over the plugins to find one capable of handling a request, plugins can only say yes or no. For this to work we would need some sort of option to allow a plugin to say "no, but ...".
I think this would be worth the effort, but this will have to wait for when I have/allocate some serieus imageio-time :)
If a user tries to read using iio.imread(..., format="EXR-FI") and FreeImage is not installed, it will ask the user to install FreeImage first.
For files that have the .exr extension this will still give a generic error, but we can discuss/look into if this should raise a warning or error that it could be read after installing FreeImage.
If no currently installed backend can fulfill the request we check the image resource for its extension. If it has an extension, we look up all plugins that are associated with this extension and check if they are installed. For each missing plugin, we inform the user in the error message that installing that plugin might resolve this error.
This should turn the above exception into something like:
img = imageio.imread(path)
...
OSError: Could not find a backend to open `path` with iomode `r`. Based on the extension, the following plugins might add capable backends:
EXR-FI: pip install imageio[freeimage]
Activity
almarklein commentedon Apr 12, 2018
That would be much better indeed. Would not be trivial to add though. When the format manager iterates over the plugins to find one capable of handling a request, plugins can only say yes or no. For this to work we would need some sort of option to allow a plugin to say "no, but ...".
I think this would be worth the effort, but this will have to wait for when I have/allocate some serieus imageio-time :)
FirefoxMetzger commentedon Nov 5, 2021
I think we can fix this soon™ (via #680 ).
If a user tries to read using
iio.imread(..., format="EXR-FI")and FreeImage is not installed, it will ask the user to install FreeImage first.For files that have the
.exrextension this will still give a generic error, but we can discuss/look into if this should raise a warning or error that it could be read after installing FreeImage.FirefoxMetzger commentedon Nov 7, 2021
Okay, this will get fixed in #680.
If no currently installed backend can fulfill the request we check the image resource for its extension. If it has an extension, we look up all plugins that are associated with this extension and check if they are installed. For each missing plugin, we inform the user in the error message that installing that plugin might resolve this error.
This should turn the above exception into something like:
@almarklein What do you think?
almarklein commentedon Nov 12, 2021
Sounds good!