diff --git a/src/codecs/hdr/decoder.rs b/src/codecs/hdr/decoder.rs index 6b2965c1fe..a994f7319a 100644 --- a/src/codecs/hdr/decoder.rs +++ b/src/codecs/hdr/decoder.rs @@ -184,31 +184,33 @@ impl Rgbe8Pixel { } impl HdrDecoder { - /// Reads Radiance HDR image header from stream ```r``` - /// if the header is valid, creates `HdrDecoder` - /// strict mode is enabled + /// Reads Radiance HDR image header from `reader` with strict mode enabled. + /// + /// In strict mode, the header is required to be well-formed. This prevents + /// certain older slightly-malformed files from being read. See + /// [`HdrDecoder::with_strictness`] for details. pub fn new(reader: R) -> ImageResult { HdrDecoder::with_strictness(reader, true) } - /// Allows reading old Radiance HDR images - #[deprecated(note = "Use `new_with_spec_compliance(reader, SpecCompliance::Lenient)` instead")] - pub fn new_nonstrict(reader: R) -> ImageResult { - Self::with_strictness(reader, false) - } - /// Create a new decoder with the given spec compliance mode. pub(crate) fn new_with_spec_compliance(reader: R, spec: SpecCompliance) -> ImageResult { Self::with_strictness(reader, spec == SpecCompliance::Strict) } - /// Reads Radiance HDR image header from stream `reader`, - /// if the header is valid, creates `HdrDecoder`. + /// Reads Radiance HDR image header from `reader`. + /// + /// In strict mode, the header is required to be well-formed. I.e. it must + /// contain a valid signature among other requirements. In non-strict mode, + /// certain malformed headers are accepted, allowing more files to be read + /// but potentially incorrectly. + /// + /// Certain older files require non-strict mode to be read. /// - /// strict enables strict mode + /// # Warning /// - /// Warning! Reading wrong file in non-strict mode could consume up to a few - /// megabytes of memory before this errors, if the file is large enough. + /// In non-strict mode, certain invalid files may consume multiple megabytes of memory + /// before an error is returned. pub fn with_strictness(mut reader: R, strict: bool) -> ImageResult> { let mut attributes = HdrMetadata::new();