Skip to content

Conversation

@197g
Copy link
Member

@197g 197g commented Aug 21, 2019

Replace free reader functions with Reader structure as sketched in this comment of #1007. This provides an api for reading image metadata and pixels without coupling to format guessing instead of adding all possible combinations of methods.

Also makes the interface for directly turning an ImageDecoder into a DynamicImage public.

Closes: #1007
Closes: #716
Closes: #577

Unresolved questions:

  • Should opening a file automatically try to guess the format from the first bytes? Or only from the path? From neither? Offer two methods. Offer a method and a builder style continuation.
  • Should the path be contained in the data stored in the Reader? This would allow other methods to emulate having opened a file, without going through the actual fs api. ImageFormat::from_path can be used.
  • Should there be a special load for formats which do not require Seek? Later, if the need arises.
  • What about formats not requiring BufRead but only Read? Easy to wrap in BufReader.

@fintelia
Copy link
Contributor

What about formats not requiring BufRead but only Read?

It seems easy enough to just dynamically create a BufReader for them. They aren't that expensive to construct

@197g 197g force-pushed the image-reader branch 2 times, most recently from 20d2d4a to 27f31bf Compare September 5, 2019 02:37
@197g 197g changed the title [WIP] Image reader Image reader Sep 5, 2019
197g added 11 commits September 25, 2019 23:26
Does not touch the public interface, only internal `_impl` variants
which are simply referenced from their new location.
Firstly, simply renames load to decode.

Also splits open into to operations:
- open, which will inspect the file contents to guess the correct format
  *before* falling back to a path.
- from_path, which imitates the old behaviour.
Don't deprecate them just yet, for now they are even the underlying
primitives instead of being wrappers around the reader.
Fixes guess_format to only change the format on successful guesses.
Minimize the commitment of public interface for now. The builder style
methods are likely the most immediately useful.
@197g
Copy link
Member Author

197g commented Sep 25, 2019

Got a weird failure, seems spurious and within the cargo tool itself.

@197g
Copy link
Member Author

197g commented Sep 25, 2019

No, it's not spurious. But I'm not sure what to make of it:
https://travis-ci.org/image-rs/image/jobs/589672851

@197g
Copy link
Member Author

197g commented Sep 25, 2019

Going to ignore it: rust-lang/cargo#7429

@197g 197g merged commit ac93e75 into image-rs:master Sep 25, 2019
@197g
Copy link
Member Author

197g commented Sep 25, 2019

I'm glad to finally have this landed. Thanks @fintelia for the review discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants