Choose a default for ambiguous formats #38
Merged
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.
save("myfile.ppm", img)
used to generate an error, because there are two formats (:PPMBinary
and:PPMText
) defined. Users will rarely care, and in almost all cases you want:PPMBinary
anyway. So I changed the behavior from "throw an error upon creating a new file when the format is ambiguous" to "choose the first one in the list".I also provided a new mechanism for forcing the format:
save(format"PPMBinary", "myfile.ppm", img)
. You might have thought thatsave(File(format"PPMBinary", "myfile.ppm"), img)
would have been the better choice, but that runs into a problem: unless the (new) Netpbm.jl package has already been manually loaded, it falls back to the "error: no saver defined for ..." method. So we need a method with distinguishable signature, and this seemed to be the obvious one.