Use libtiff compatible weezl configuration (#276)

This commit is contained in:
Vladimir Kuznetsov authored and GitHub committed 2025-06-29 10:24:28 -07:00
1 parent 7648317643
commit 816fb85304
2 files changed
+5 -2

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ half = { version = "2.4.1" }
quick-error = "2.0.1" quick-error = "2.0.1"
flate2 = { version = "1.0.20", optional = true } flate2 = { version = "1.0.20", optional = true }
weezl = { version = "0.1.0", optional = true } weezl = { version = "0.1.10", optional = true }
zstd = { version = "0.13", optional = true } zstd = { version = "0.13", optional = true }
zune-jpeg = { version = "0.4.17", optional = true } zune-jpeg = { version = "0.4.17", optional = true }
+4 -1
View File
@@ -158,12 +158,15 @@ pub struct LZWReader<R: Read> {
impl<R: Read> LZWReader<R> { impl<R: Read> LZWReader<R> {
/// Wraps a reader /// Wraps a reader
pub fn new(reader: R, compressed_length: usize) -> LZWReader<R> { pub fn new(reader: R, compressed_length: usize) -> LZWReader<R> {
let configuration =
weezl::decode::Configuration::with_tiff_size_switch(weezl::BitOrder::Msb, 8)
.with_yield_on_full_buffer(true);
Self { Self {
reader: BufReader::with_capacity( reader: BufReader::with_capacity(
(32 * 1024).min(compressed_length), (32 * 1024).min(compressed_length),
reader.take(u64::try_from(compressed_length).unwrap()), reader.take(u64::try_from(compressed_length).unwrap()),
), ),
decoder: weezl::decode::Decoder::with_tiff_size_switch(weezl::BitOrder::Msb, 8), decoder: configuration.build(),
} }
} }
} }