Skip to content

Commit 0d60e8b

Browse files
authored
Expose zc level 0 (uncompressed) πŸš€ (#641)
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 πŸ™‚.
1 parent 0f24120 commit 0d60e8b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

β€ŽMANUAL.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Options:
132132
CPU cores.
133133

134134
--zc <level>
135-
Deflate compression level (1-12) for main compression trials. The levels here are defined
135+
Deflate compression level (0-12) for main compression trials. The levels here are defined
136136
by the libdeflate compression library.
137137

138138
The default value depends on the optimization level preset.

β€Žsrc/cli.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ CPU cores.")
259259
)
260260
.arg(
261261
Arg::new("compression")
262-
.help("Deflate compression level (1-12)")
262+
.help("Deflate compression level (0-12)")
263263
.long_help("\
264-
Deflate compression level (1-12) for main compression trials. The levels here are defined \
264+
Deflate compression level (0-12) for main compression trials. The levels here are defined \
265265
by the libdeflate compression library.
266266
267267
The default value depends on the optimization level preset.")
268268
.long("zc")
269269
.value_name("level")
270-
.value_parser(1..=12)
270+
.value_parser(0..=12)
271271
.conflicts_with("zopfli"),
272272
)
273273
.arg(

β€Žsrc/deflate/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub use zopfli_oxipng::deflate as zopfli_deflate;
1616
pub enum Deflaters {
1717
/// Use libdeflater.
1818
Libdeflater {
19-
/// Which compression level to use on the file (1-12)
19+
/// Which compression level to use on the file (0-12)
2020
compression: u8,
2121
},
2222
#[cfg(feature = "zopfli")]

β€Žsrc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ fn optimize_raw(
413413
deadline: Arc<Deadline>,
414414
max_size: Option<usize>,
415415
) -> Option<PngData> {
416-
// Libdeflate has four algorithms: 1-4 = 'greedy', 5-7 = 'lazy', 8-9 = 'lazy2', 10-12 = 'near-optimal'
416+
// Libdeflate has four algorithms: 0 = 'uncompressed', 1-4 = 'greedy', 5-7 = 'lazy', 8-9 = 'lazy2', 10-12 = 'near-optimal'
417417
// 5 is the minimumm required for a decent evaluation result
418418
// 7 is not noticeably slower than 5 and improves evaluation of filters in 'fast' mode (o2 and lower)
419419
// 8 is a little slower but not noticeably when used only for reductions (o3 and higher)

0 commit comments

Comments
Β (0)