Add with_format_from_path to ImageReaderOptions#3023
Open
RunDevelopment wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change makes the logic turning a path to a format in
ImageReaderOptions::openpublic using the newImageReaderOptions::with_format_from_pathfunction.The main use case here is that it's now possible (and easy) to create an
ImageReaderOptions(andImageReader) with the exact same semantics as::openbut with a custom reader. This previously wasn't possible, because we had no way to set the format based on a path or file extension.Note: I view this as orthogonal to changes like #2683 and #2662. My main goal here is that
::openshouldn't have magic sauce that users can't recreate. I also want a sort of progressive disclosure, where we don't let the user fall directly into the dark pits of complexity but provide a path downward that they can descend at their own pace.This resolves #1659. The user can now create their own
BufReaderwith a given capacity and pass it toImageReaderOptions::newlike so:Bikeshedding: I couldn't decide between making the new method builder-like and setter-like. The things on
ImageReaderOptionsare a weird mix of functions that look like they belong to a builder and functions that don't. For example,::limitsis a setter and::formatis a getter. I went withwith_format_from_pathto mimicwith_guessed_format, but I'm not married to the idea.