From 816fb85304e5fe873152bef770d0f23c284ec4d0 Mon Sep 17 00:00:00 2001 From: Vladimir Kuznetsov Date: Sun, 29 Jun 2025 18:24:28 +0100 Subject: [PATCH] Use libtiff compatible weezl configuration (#276) --- Cargo.toml | 2 +- src/decoder/stream.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c43f4a4..ae4f4e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ half = { version = "2.4.1" } quick-error = "2.0.1" 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 } zune-jpeg = { version = "0.4.17", optional = true } diff --git a/src/decoder/stream.rs b/src/decoder/stream.rs index 6c13ab1..979f080 100644 --- a/src/decoder/stream.rs +++ b/src/decoder/stream.rs @@ -158,12 +158,15 @@ pub struct LZWReader { impl LZWReader { /// Wraps a reader pub fn new(reader: R, compressed_length: usize) -> LZWReader { + let configuration = + weezl::decode::Configuration::with_tiff_size_switch(weezl::BitOrder::Msb, 8) + .with_yield_on_full_buffer(true); Self { reader: BufReader::with_capacity( (32 * 1024).min(compressed_length), reader.take(u64::try_from(compressed_length).unwrap()), ), - decoder: weezl::decode::Decoder::with_tiff_size_switch(weezl::BitOrder::Msb, 8), + decoder: configuration.build(), } } }