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
It would be nice to be able to handle preferences for plugins.
For example, tifffile.py should be always used as the default plugin for TIF files, if available, since it handles the widest assortment of TIF foibles.
Also, the user should be able to specify the desired plugin three ways:
If we put the tifffile import beforr the freeimage, it should be fine.
How automatic format selection works: when a file should be read or written, imageio asks each format (a plugin provides one or more formats) whether it can handle it, in the order that they're registered. The first format that says it can do it, gets to do it. Formats can look at file extensions but most also inspects the first few bytes.
The user can also provide the format explicitly as the second arg to imread or imwrite.
So IIUC you propose to allow users to specify the plugins based on extensions too? I suppose we can do that, though I am not sure how necessary it is; for tiff we should just make tiffile the default, and if people really want to use freeimage, they can.
But, then they wouldn't benefit from the wrappers you have in place.
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 8:35 AM, Almar Klein [email protected]
wrote:
The global preference order can be determined by the order in which plugins are registered, or imported in https://github.com/imageio/imageio/blob/master/imageio/plugins/__init__.py.
If we put the tifffile import beforr the freeimage, it should be fine.
How automatic format selection works: when a file should be read or written, imageio asks each format (a plugin provides one or more formats) whether it can handle it, in the order that they're registered. The first format that says it can do it, gets to do it. Formats can look at file extensions but most also inspects the first few bytes.
The user can also provide the format explicitly as the second arg to imread or imwrite.
So IIUC you propose to allow users to specify the plugins based on extensions too? I suppose we can do that, though I am not sure how necessary it is; for tiff we should just make tiffile the default, and if people really want to use freeimage, they can.
Reply to this email directly or view it on GitHub: #93 (comment)
If the user knows that the only way to open their particular files properly is to use a specific plugin, they should be able to select that plugin. The plugin is guaranteed to have uniform behavior with other plugins in imageio. If they wanted to use the other library to load it (such as astropy), they could do so, but then they just find ways not to use imageio directly...
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 8:41 AM, Almar Klein [email protected]
wrote:
Sorry, I don't follow ...
Reply to this email directly or view it on GitHub: #93 (comment)
So, you mean that imageio.imread('myfile.tif', 'tifffile') is not sufficient, because the user might be using astropy.imread('myfile.tif'), which might use imageio, but now there is no way to specify the plugin?
Let's say tifffile were not the first plugin. If the user had a TIFF file that freeimage could not load, they would be sunk, unless they could use imageio.imread('myfile.tif', use_plugin='tifffile').
@blink1073 what you are saying imageio.imread('myfile.tif', 'tifffile') does already work. A user can specify the plugin as the 2nd argument. Right @almarklein?
The docstring is not clear enough in this regard, if that is the case.
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 11:46 AM, Anthony Tanbakuchi [email protected] wrote:
@blink1073 what you are saying imageio.imread('myfile.tif', 'tifffile') does already work. A user can specify the plugin as the 2nd argument. Right @almarklein?
Reply to this email directly or view it on GitHub: #93 (comment)
Okay, I think this is fine as long as you expose a list of available formats by name.
Right now it is available as [f.name for f in imageio.formats._formats], but perhaps this could be imageio.available_formats. This would also show the order of precedence.
Activity
almarklein commentedon Jul 4, 2015
The global preference order can be determined by the order in which plugins are registered, or imported in https://github.com/imageio/imageio/blob/master/imageio/plugins/__init__.py.
If we put the tifffile import beforr the freeimage, it should be fine.
How automatic format selection works: when a file should be read or written, imageio asks each format (a plugin provides one or more formats) whether it can handle it, in the order that they're registered. The first format that says it can do it, gets to do it. Formats can look at file extensions but most also inspects the first few bytes.
The user can also provide the format explicitly as the second arg to
imreadorimwrite.So IIUC you propose to allow users to specify the plugins based on extensions too? I suppose we can do that, though I am not sure how necessary it is; for tiff we should just make tiffile the default, and if people really want to use freeimage, they can.
blink1073 commentedon Jul 4, 2015
But, then they wouldn't benefit from the wrappers you have in place.
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 8:35 AM, Almar Klein [email protected]
wrote:
almarklein commentedon Jul 4, 2015
Sorry, I don't follow ...
blink1073 commentedon Jul 4, 2015
If the user knows that the only way to open their particular files properly is to use a specific plugin, they should be able to select that plugin. The plugin is guaranteed to have uniform behavior with other plugins in imageio. If they wanted to use the other library to load it (such as astropy), they could do so, but then they just find ways not to use imageio directly...
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 8:41 AM, Almar Klein [email protected]
wrote:
almarklein commentedon Jul 4, 2015
So, you mean that
imageio.imread('myfile.tif', 'tifffile')is not sufficient, because the user might be usingastropy.imread('myfile.tif'), which might use imageio, but now there is no way to specify the plugin?blink1073 commentedon Jul 4, 2015
Let's say
tifffilewere not the first plugin. If the user had a TIFF file thatfreeimagecould not load, they would be sunk, unless they could useimageio.imread('myfile.tif', use_plugin='tifffile').west-rynes commentedon Jul 4, 2015
@blink1073 what you are saying imageio.imread('myfile.tif', 'tifffile') does already work. A user can specify the plugin as the 2nd argument. Right @almarklein?
blink1073 commentedon Jul 4, 2015
The docstring is not clear enough in this regard, if that is the case.
—
Sent from Mailbox
On Sat, Jul 4, 2015 at 11:46 AM, Anthony Tanbakuchi
[email protected] wrote:
almarklein commentedon Jul 4, 2015
http://imageio.readthedocs.org/en/latest/userapi.html#imageio.imread
Mmm, maybe it can be more clear how the format can be specified, perhaps with an example.
BTW: if there are two plugins that can read the same format, the "best" one should be tried first. tiffile > freeimage, ffmpeg > avbin.
blink1073 commentedon Jul 4, 2015
Agreed. You're also missing the word "plugin" in the description of
format.blink1073 commentedon Jul 4, 2015
Or, I am really confused and just need to read the source at this point.
blink1073 commentedon Jul 4, 2015
Okay, so a plugin registers one or more formats that each have one or more possible extensions.
blink1073 commentedon Jul 4, 2015
So in the case of
astropy, we would register agdalformat.blink1073 commentedon Jul 4, 2015
Okay, I think this is fine as long as you expose a list of available formats by name.
Right now it is available as
[f.name for f in imageio.formats._formats], but perhaps this could beimageio.available_formats. This would also show the order of precedence.blink1073 commentedon Jul 4, 2015
I will submit a PR if you agree.
almarklein commentedon Jul 4, 2015
There's a list in the docs, but to get a list from the repl would be good, yes.
almarklein commentedon Dec 6, 2016
This is implemented in #167:
IMAGEIO_FORMAT_ORDER, it is split on commas and fed to ...imageio.formats.sort(...), which sorts the plugins so that plugin selection can be influenced.