From c1222368b457cf44d736af026802424e09d855cc Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 22 May 2023 08:11:36 +1200 Subject: [PATCH] Deinterlace by default --- src/lib.rs | 4 ++-- src/main.rs | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 46886f33..82856624 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,7 +159,7 @@ pub struct Options { /// /// `Some(x)` will change the file to interlacing mode `x`. /// - /// Default: `None` + /// Default: `Some(None)` pub interlace: Option, /// Whether to allow transparent pixels to be altered to improve compression. pub optimize_alpha: bool, @@ -296,7 +296,7 @@ impl Default for Options { force: false, preserve_attrs: false, filter: indexset! {RowFilter::None, RowFilter::Sub, RowFilter::Entropy, RowFilter::Bigrams}, - interlace: None, + interlace: Some(Interlacing::None), optimize_alpha: false, bit_depth_reduction: true, color_type_reduction: true, diff --git a/src/main.rs b/src/main.rs index 585f7086..a1032d7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -144,13 +144,14 @@ fn main() { ) .arg( Arg::new("interlace") - .help("PNG interlace type") + .help("PNG interlace type - Default: 0") .short('i') .long("interlace") .takes_value(true) - .value_name("0/1") + .value_name("type") .possible_value("0") - .possible_value("1"), + .possible_value("1") + .possible_value("keep"), ) .arg( Arg::new("verbose") @@ -394,7 +395,11 @@ fn parse_opts_into_struct( }; if let Some(x) = matches.value_of("interlace") { - opts.interlace = x.parse::().unwrap().try_into().ok(); + opts.interlace = if x == "keep" { + None + } else { + x.parse::().unwrap().try_into().ok() + }; } if let Some(x) = matches.value_of("filters") {