Add --ziwi option

This commit is contained in:
Andrew 2025-08-05 19:32:36 +12:00
parent 8a5a3ab69e
commit be608ea876
2 changed files with 15 additions and 0 deletions

View file

@ -340,6 +340,17 @@ speed up compression for large files. This option requires '--zopfli' to be set.
.value_parser(value_parser!(NonZeroU64))
.requires("zopfli"),
)
.arg(
Arg::new("iterations-without-improvement")
.hide_short_help(true)
.long_help("\
Stop Zopfli compression after this number of iterations without improvement. Use this in \
conjunction with a high value for '--zi' to achieve better compression in reasonable time.")
.long("ziwi")
.value_name("iterations")
.value_parser(value_parser!(NonZeroU64))
.requires("zopfli"),
)
.arg(
Arg::new("timeout")
.help("Maximum amount of time to spend on optimizations")

View file

@ -334,8 +334,12 @@ fn parse_opts_into_struct(
#[cfg(feature = "zopfli")]
if matches.get_flag("zopfli") {
let iteration_count = *matches.get_one::<NonZeroU64>("iterations").unwrap();
let iterations_without_improvement = *matches
.get_one::<NonZeroU64>("iterations-without-improvement")
.unwrap_or(&NonZeroU64::MAX);
opts.deflater = Deflater::Zopfli(ZopfliOptions {
iteration_count,
iterations_without_improvement,
..Default::default()
});
}