From 0d60e8b7c6e8bca86c19fa8e29697e2363182a14 Mon Sep 17 00:00:00 2001 From: Galaxy4594 <164440799+Galaxy4594@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:32:28 -0700 Subject: [PATCH] =?UTF-8?q?Expose=20zc=20level=200=20(uncompressed)=20?= =?UTF-8?q?=F0=9F=9A=80=20(#641)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow the creation of PNGs with uncompressed deflate streams via level 0 of libdeflate. If you want a glorified BMP with delta filters, this change will make your dreams come true 🙂. --- MANUAL.txt | 2 +- src/cli.rs | 6 +++--- src/deflate/mod.rs | 2 +- src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MANUAL.txt b/MANUAL.txt index 5a49b91f..8c6dba9d 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -132,7 +132,7 @@ Options: CPU cores. --zc - Deflate compression level (1-12) for main compression trials. The levels here are defined + Deflate compression level (0-12) for main compression trials. The levels here are defined by the libdeflate compression library. The default value depends on the optimization level preset. diff --git a/src/cli.rs b/src/cli.rs index e3d9c72d..cc861650 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -259,15 +259,15 @@ CPU cores.") ) .arg( Arg::new("compression") - .help("Deflate compression level (1-12)") + .help("Deflate compression level (0-12)") .long_help("\ -Deflate compression level (1-12) for main compression trials. The levels here are defined \ +Deflate compression level (0-12) for main compression trials. The levels here are defined \ by the libdeflate compression library. The default value depends on the optimization level preset.") .long("zc") .value_name("level") - .value_parser(1..=12) + .value_parser(0..=12) .conflicts_with("zopfli"), ) .arg( diff --git a/src/deflate/mod.rs b/src/deflate/mod.rs index 18f4812d..af2fca54 100644 --- a/src/deflate/mod.rs +++ b/src/deflate/mod.rs @@ -16,7 +16,7 @@ pub use zopfli_oxipng::deflate as zopfli_deflate; pub enum Deflaters { /// Use libdeflater. Libdeflater { - /// Which compression level to use on the file (1-12) + /// Which compression level to use on the file (0-12) compression: u8, }, #[cfg(feature = "zopfli")] diff --git a/src/lib.rs b/src/lib.rs index 44ca106a..cf6f0e47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -413,7 +413,7 @@ fn optimize_raw( deadline: Arc, max_size: Option, ) -> Option { - // Libdeflate has four algorithms: 1-4 = 'greedy', 5-7 = 'lazy', 8-9 = 'lazy2', 10-12 = 'near-optimal' + // Libdeflate has four algorithms: 0 = 'uncompressed', 1-4 = 'greedy', 5-7 = 'lazy', 8-9 = 'lazy2', 10-12 = 'near-optimal' // 5 is the minimumm required for a decent evaluation result // 7 is not noticeably slower than 5 and improves evaluation of filters in 'fast' mode (o2 and lower) // 8 is a little slower but not noticeably when used only for reductions (o3 and higher)