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
Yes, it is expected. Ignoring irrelevant kwargs would mean a risk to ignore kwargs that simply had a typo. I do see how this causes pain in your use-case though. Something like #455 would help for the rotation-case.
I also welcome ideas to work with this in a more generic (and preferably elegant) way ...
I am back on this task and the solution I ended up going with is a light wrapper function that receives a ignore_orientation flag, which if True, will perform the inverse rotation of _rotate(). Not the most elegant, but since my logic to detect Orientation returns None on failure, and my custom rotate() is a NOP when passed None, I can map over my messy dataset.
I have an idea on how to possibly harmonize the above issue with another shortcoming I find with the imread interface, which is that it is challenging to know what options I can pass if I do not know what type of image I am dealing with ahead of time. It would be nice to capture "If PNG, do these options, if JPEG, do these other options" in a succinct and strongly typed way.
Just throwing this idea out there. What if Requests were given an additional keyword parameter, let's call it plugin_args, of type Dict[str, Dict[str, Any]]. This would be a dict of FormatClassName: kwargs, e.g.:
If plugin_args were present, the reader/writer obtained during imread/imwrite would have those kwargs applied, iff the string matches the class name. This might be pushing the limits of complexity of the intended use of imread, and might be better handled with an additional function ("imread_adaptive" or some more fitting name). I might hack around with this.
Activity
almarklein commentedon Jun 17, 2019
Yes, it is expected. Ignoring irrelevant kwargs would mean a risk to ignore kwargs that simply had a typo. I do see how this causes pain in your use-case though. Something like #455 would help for the rotation-case.
I also welcome ideas to work with this in a more generic (and preferably elegant) way ...
xkortex commentedon Feb 19, 2020
I am back on this task and the solution I ended up going with is a light wrapper function that receives a
ignore_orientationflag, which if True, will perform the inverse rotation of_rotate(). Not the most elegant, but since my logic to detect Orientation returns None on failure, and my customrotate()is a NOP when passed None, I can map over my messy dataset.I have an idea on how to possibly harmonize the above issue with another shortcoming I find with the
imreadinterface, which is that it is challenging to know what options I can pass if I do not know what type of image I am dealing with ahead of time. It would be nice to capture "If PNG, do these options, if JPEG, do these other options" in a succinct and strongly typed way.Just throwing this idea out there. What if
Requestswere given an additional keyword parameter, let's call itplugin_args, of typeDict[str, Dict[str, Any]]. This would be a dict of FormatClassName: kwargs, e.g.:If plugin_args were present, the reader/writer obtained during imread/imwrite would have those kwargs applied, iff the string matches the class name. This might be pushing the limits of complexity of the intended use of imread, and might be better handled with an additional function ("imread_adaptive" or some more fitting name). I might hack around with this.