From d93dd21a180cae7cdbeda4a562d3004cf0ff6efe Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 1 Sep 2025 13:20:43 +1200 Subject: [PATCH] Prefer off/on for --interlace --- src/cli.rs | 16 ++++++++-------- src/main.rs | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index aa5431b3..451dd349 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -164,21 +164,21 @@ transformation and may be unsuitable for some applications.") ) .arg( Arg::new("interlace") - .help("Set PNG interlacing type (0, 1, keep)") + .help("Set PNG interlacing (off, on, keep)") .long_help("\ -Set the PNG interlacing type, where is one of: +Set the PNG interlacing mode, where is one of: - 0 => Remove interlacing from all images that are processed - 1 => Apply Adam7 interlacing on all images that are processed - keep => Keep the existing interlacing type of each image + off => Remove interlacing from all images that are processed + on => Apply Adam7 interlacing on all images that are processed + keep => Keep the existing interlacing mode of each image Note that interlacing can add 25-50% to the size of an optimized image. Only use it if you \ believe the benefits outweigh the costs for your use case.") .short('i') .long("interlace") - .value_name("type") - .value_parser(["0", "1", "keep"]) - .default_value("0") + .value_name("mode") + .value_parser(["off", "on", "keep", "0", "1"]) + .default_value("off") .default_value_if("no-reductions", ArgPredicate::IsPresent, "keep") .hide_possible_values(true), ) diff --git a/src/main.rs b/src/main.rs index 3e68852b..f2ee9e3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -278,7 +278,11 @@ fn parse_opts_into_struct( opts.idat_recoding = !matches.get_flag("no-recoding"); if let Some(x) = matches.get_one::("interlace") { - opts.interlace = if x == "keep" { None } else { Some(x == "1") }; + opts.interlace = match x.as_str() { + "off" | "0" => Some(false), + "on" | "1" => Some(true), + _ => None, // keep + }; } if let Some(keep) = matches.get_one::("keep") {