From e3ba535a79ae276143d0ddcedff41ad12c5aafec Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Wed, 10 Jan 2018 20:54:15 -0500 Subject: [PATCH] Add some changes and fixes around how the output file is handled See changelog for details --- CHANGELOG.md | 8 ++- src/lib.rs | 51 ++++++++------ src/main.rs | 6 +- tests/filters.rs | 134 ++++++++++++++++++------------------ tests/flags.rs | 28 ++++---- tests/interlaced.rs | 112 +++++++++++++++--------------- tests/reduction.rs | 164 ++++++++++++++++++++++---------------------- tests/regression.rs | 38 +++++----- 8 files changed, 276 insertions(+), 265 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e94fbac0..8418f5b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ -### Version 0.18.4 +### Version 0.19.0 + - [SEMVER_MAJOR] Default to overwriting the input file if `out_file` is not set. + This does not affect the CLI, but with the library, it was easy to forget to set the `out_file`, + and there was no warning that no output file would be written. - Bump dependencies, reduces binary size by a considerable amount - Hide all modules from documentation, and only export the specific structures that should be public. Previously there were too many implementation details made public. The modules are still public for the purposes of our integration tests, but we strongly advice against using undocumented modules. These may become private in the future. - Internal refactoring and code cleanup + - Fix an error message that was displaying the wrong file path + - Fix an issue where the output file would not be written if the input was already optimized, + even if the output path was different from the input path ### Version 0.18.3 - Return exit code of 1 if an error occurred while processing a file using the CLI app ([#93](https://github.com/shssoichiro/oxipng/issues/93)) diff --git a/src/lib.rs b/src/lib.rs index 9f10369a..f202bf29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,9 +45,11 @@ pub struct Options { /// Whether the input file should be backed up before writing the output /// Default: `false` pub backup: bool, - /// Path to write the output file to - pub out_file: PathBuf, + /// Path to write the output file to. If not set, the application will default to + /// overwriting the input file. + pub out_file: Option, /// Used only in CLI interface + #[doc(hidden)] pub out_dir: Option, /// Write to stdout instead of a file /// Default: `false` @@ -59,6 +61,7 @@ pub struct Options { /// Default: `false` pub pretend: bool, /// Used only in CLI interface + #[doc(hidden)] pub recursive: bool, /// Overwrite existing output files /// Default: `true` @@ -279,7 +282,7 @@ impl Default for Options { Options { backup: false, - out_file: PathBuf::new(), + out_file: None, out_dir: None, stdout: false, pretend: false, @@ -310,26 +313,32 @@ impl Default for Options { } /// Perform optimization on the input file using the options provided -pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), PngError> { +pub fn optimize(input_path: &Path, opts: &Options) -> Result<(), PngError> { // Initialize the thread pool with correct number of threads let thread_count = opts.threads; let _ = rayon::initialize(rayon::Configuration::new().num_threads(thread_count)); // Read in the file and try to decode as PNG. if opts.verbosity.is_some() { - eprintln!("Processing: {}", filepath.to_str().unwrap()); + eprintln!("Processing: {}", input_path.to_str().unwrap()); } - let in_file = Path::new(filepath); - let in_data = PngData::read_file(in_file)?; + let in_data = PngData::read_file(input_path)?; let mut png = PngData::from_slice(&in_data, opts.fix_errors)?; + let output_path = opts.out_file + .clone() + .unwrap_or_else(|| input_path.to_path_buf()); // Run the optimizer on the decoded PNG. - let optimized_output = optimize_png(&mut png, &in_data, opts)?; + let mut optimized_output = optimize_png(&mut png, &in_data, opts)?; if is_fully_optimized(in_data.len(), optimized_output.len(), opts) { eprintln!("File already optimized"); - return Ok(()); + if input_path == output_path { + return Ok(()); + } else { + optimized_output = in_data; + } } if opts.pretend { @@ -338,18 +347,16 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), PngError> { } } else { if opts.backup { - match copy( - in_file, - in_file.with_extension(format!( - "bak.{}", - in_file.extension().unwrap().to_str().unwrap() - )), - ) { + let backup_file = input_path.with_extension(format!( + "bak.{}", + input_path.extension().unwrap().to_str().unwrap() + )); + match copy(input_path, &backup_file) { Ok(x) => x, Err(_) => { return Err(PngError::new(&format!( "Unable to write to backup file at {}", - opts.out_file.display() + backup_file.display() ))) } }; @@ -362,18 +369,18 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), PngError> { Err(_) => return Err(PngError::new("Unable to write to stdout")), } } else { - let out_file = match File::create(&opts.out_file) { + let out_file = match File::create(&output_path) { Ok(x) => x, Err(_) => { return Err(PngError::new(&format!( "Unable to write to file {}", - opts.out_file.display() + output_path.display() ))) } }; if opts.preserve_attrs { - match File::open(filepath) { + match File::open(input_path) { Ok(f) => { match f.metadata() { Ok(metadata) => { @@ -406,12 +413,12 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), PngError> { let mut buffer = BufWriter::new(out_file); match buffer.write_all(&optimized_output) { Ok(_) => if opts.verbosity.is_some() { - eprintln!("Output: {}", opts.out_file.display()); + eprintln!("Output: {}", output_path.display()); }, Err(_) => { return Err(PngError::new(&format!( "Unable to write to file {}", - opts.out_file.display() + output_path.display() ))) } } diff --git a/src/main.rs b/src/main.rs index c945bdb4..399010b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -272,9 +272,7 @@ fn handle_optimization(inputs: Vec, opts: &Options) -> Result<(), PngEr return res; } if let Some(ref out_dir) = current_opts.out_dir { - current_opts.out_file = out_dir.join(input.file_name().unwrap()); - } else if current_opts.out_file.components().count() == 0 { - current_opts.out_file = input.clone(); + current_opts.out_file = Some(out_dir.join(input.file_name().unwrap())); } let cur_result = oxipng::optimize(&input, ¤t_opts); res.and(cur_result) @@ -342,7 +340,7 @@ fn parse_opts_into_struct(matches: &ArgMatches) -> Result { } if let Some(x) = matches.value_of("output_file") { - opts.out_file = PathBuf::from(x); + opts.out_file = Some(PathBuf::from(x)); } if matches.is_present("stdout") { diff --git a/tests/filters.rs b/tests/filters.rs index d1c46505..0d976fff 100644 --- a/tests/filters.rs +++ b/tests/filters.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; fn get_opts(input: &Path) -> oxipng::Options { let mut options = oxipng::Options::default(); - options.out_file = input.with_extension("out.png").to_owned(); + options.out_file = Some(input.with_extension("out.png").to_owned()); options.verbosity = None; options.force = true; let mut filter = HashSet::new(); @@ -60,7 +60,7 @@ fn filter_0_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -79,7 +79,7 @@ fn filter_1_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -98,7 +98,7 @@ fn filter_2_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -117,7 +117,7 @@ fn filter_3_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -136,7 +136,7 @@ fn filter_4_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -155,7 +155,7 @@ fn filter_5_for_rgba_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -174,7 +174,7 @@ fn filter_0_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -193,7 +193,7 @@ fn filter_1_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -212,7 +212,7 @@ fn filter_2_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -231,7 +231,7 @@ fn filter_3_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -250,7 +250,7 @@ fn filter_4_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -269,7 +269,7 @@ fn filter_5_for_rgba_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -288,7 +288,7 @@ fn filter_0_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -307,7 +307,7 @@ fn filter_1_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -326,7 +326,7 @@ fn filter_2_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -345,7 +345,7 @@ fn filter_3_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -364,7 +364,7 @@ fn filter_4_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -383,7 +383,7 @@ fn filter_5_for_rgb_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -402,7 +402,7 @@ fn filter_0_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -421,7 +421,7 @@ fn filter_1_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -440,7 +440,7 @@ fn filter_2_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -459,7 +459,7 @@ fn filter_3_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -478,7 +478,7 @@ fn filter_4_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -497,7 +497,7 @@ fn filter_5_for_rgb_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -516,7 +516,7 @@ fn filter_0_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -535,7 +535,7 @@ fn filter_1_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -554,7 +554,7 @@ fn filter_2_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -573,7 +573,7 @@ fn filter_3_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -592,7 +592,7 @@ fn filter_4_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -611,7 +611,7 @@ fn filter_5_for_grayscale_alpha_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -630,7 +630,7 @@ fn filter_0_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -649,7 +649,7 @@ fn filter_1_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -668,7 +668,7 @@ fn filter_2_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -687,7 +687,7 @@ fn filter_3_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -706,7 +706,7 @@ fn filter_4_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -725,7 +725,7 @@ fn filter_5_for_grayscale_alpha_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -744,7 +744,7 @@ fn filter_0_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -763,7 +763,7 @@ fn filter_1_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -782,7 +782,7 @@ fn filter_2_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -801,7 +801,7 @@ fn filter_3_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -820,7 +820,7 @@ fn filter_4_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -839,7 +839,7 @@ fn filter_5_for_grayscale_16() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -858,7 +858,7 @@ fn filter_0_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -877,7 +877,7 @@ fn filter_1_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -896,7 +896,7 @@ fn filter_2_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -915,7 +915,7 @@ fn filter_3_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -934,7 +934,7 @@ fn filter_4_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -953,7 +953,7 @@ fn filter_5_for_grayscale_8() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -972,7 +972,7 @@ fn filter_0_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -991,7 +991,7 @@ fn filter_1_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1010,7 +1010,7 @@ fn filter_2_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1029,7 +1029,7 @@ fn filter_3_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1048,7 +1048,7 @@ fn filter_4_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1067,7 +1067,7 @@ fn filter_5_for_palette_4() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1086,7 +1086,7 @@ fn filter_0_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1105,7 +1105,7 @@ fn filter_1_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1124,7 +1124,7 @@ fn filter_2_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1143,7 +1143,7 @@ fn filter_3_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1162,7 +1162,7 @@ fn filter_4_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1181,7 +1181,7 @@ fn filter_5_for_palette_2() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1200,7 +1200,7 @@ fn filter_0_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1219,7 +1219,7 @@ fn filter_1_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1238,7 +1238,7 @@ fn filter_2_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(2); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1257,7 +1257,7 @@ fn filter_3_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(3); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1276,7 +1276,7 @@ fn filter_4_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(4); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1295,7 +1295,7 @@ fn filter_5_for_palette_1() { let mut opts = get_opts(&input); opts.filter = HashSet::new(); opts.filter.insert(5); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, diff --git a/tests/flags.rs b/tests/flags.rs index eb6d2e60..6558ec9f 100644 --- a/tests/flags.rs +++ b/tests/flags.rs @@ -12,7 +12,7 @@ use std::path::PathBuf; fn get_opts(input: &Path) -> oxipng::Options { let mut options = oxipng::Options::default(); - options.out_file = input.with_extension("out.png").to_owned(); + options.out_file = Some(input.with_extension("out.png").to_owned()); options.verbosity = None; options.force = true; let mut filter = HashSet::new(); @@ -61,7 +61,7 @@ fn verbose_mode() { let input = PathBuf::from("tests/files/verbose_mode.png"); let mut opts = get_opts(&input); opts.verbosity = Some(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -79,7 +79,7 @@ fn strip_headers_list() { let input = PathBuf::from("tests/files/strip_headers_list.png"); let mut opts = get_opts(&input); opts.strip = Headers::Some(vec!["iCCP".to_owned(), "tEXt".to_owned()]); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -113,7 +113,7 @@ fn strip_headers_safe() { let input = PathBuf::from("tests/files/strip_headers_safe.png"); let mut opts = get_opts(&input); opts.strip = Headers::Safe; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -147,7 +147,7 @@ fn strip_headers_all() { let input = PathBuf::from("tests/files/strip_headers_all.png"); let mut opts = get_opts(&input); opts.strip = Headers::All; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -181,7 +181,7 @@ fn strip_headers_none() { let input = PathBuf::from("tests/files/strip_headers_none.png"); let mut opts = get_opts(&input); opts.strip = Headers::None; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -215,7 +215,7 @@ fn interlacing_0_to_1() { let input = PathBuf::from("tests/files/interlacing_0_to_1.png"); let mut opts = get_opts(&input); opts.interlace = Some(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -245,7 +245,7 @@ fn interlacing_1_to_0() { let input = PathBuf::from("tests/files/interlacing_1_to_0.png"); let mut opts = get_opts(&input); opts.interlace = Some(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -275,7 +275,7 @@ fn interlacing_0_to_1_small_files() { let input = PathBuf::from("tests/files/interlacing_0_to_1_small_files.png"); let mut opts = get_opts(&input); opts.interlace = Some(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -309,7 +309,7 @@ fn interlacing_1_to_0_small_files() { let input = PathBuf::from("tests/files/interlacing_1_to_0_small_files.png"); let mut opts = get_opts(&input); opts.interlace = Some(0); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -346,7 +346,7 @@ fn interlaced_0_to_1_other_filter_mode() { let mut filter = HashSet::new(); filter.insert(4); opts.filter = filter; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -376,7 +376,7 @@ fn preserve_attrs() { let input = PathBuf::from("tests/files/preserve_attrs.png"); let mut opts = get_opts(&input); opts.preserve_attrs = true; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -396,7 +396,7 @@ fn fix_errors() { let input = PathBuf::from("tests/files/fix_errors.png"); let mut opts = get_opts(&input); opts.fix_errors = true; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -429,7 +429,7 @@ fn zopfli_mode() { let input = PathBuf::from("tests/files/zopfli_mode.png"); let mut opts = get_opts(&input); opts.deflate = Deflaters::Zopfli; - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, diff --git a/tests/interlaced.rs b/tests/interlaced.rs index ad2d7a43..9c70a63d 100644 --- a/tests/interlaced.rs +++ b/tests/interlaced.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; fn get_opts(input: &Path) -> oxipng::Options { let mut options = oxipng::Options::default(); - options.out_file = input.with_extension("out.png").to_owned(); + options.out_file = Some(input.with_extension("out.png").to_owned()); options.verbosity = None; options.force = true; let mut filter = HashSet::new(); @@ -59,7 +59,7 @@ fn test_it_converts( fn interlaced_rgba_16_should_be_rgba_16() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_rgba_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -76,7 +76,7 @@ fn interlaced_rgba_16_should_be_rgba_16() { fn interlaced_rgba_16_should_be_rgba_8() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_rgba_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -93,7 +93,7 @@ fn interlaced_rgba_16_should_be_rgba_8() { fn interlaced_rgba_8_should_be_rgba_8() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_rgba_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -110,7 +110,7 @@ fn interlaced_rgba_8_should_be_rgba_8() { fn interlaced_rgba_16_should_be_rgb_16() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_rgb_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -127,7 +127,7 @@ fn interlaced_rgba_16_should_be_rgb_16() { fn interlaced_rgba_16_should_be_rgb_8() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -144,7 +144,7 @@ fn interlaced_rgba_16_should_be_rgb_8() { fn interlaced_rgba_8_should_be_rgb_8() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -161,7 +161,7 @@ fn interlaced_rgba_8_should_be_rgb_8() { fn interlaced_rgba_16_should_be_palette_8() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -178,7 +178,7 @@ fn interlaced_rgba_16_should_be_palette_8() { fn interlaced_rgba_8_should_be_palette_8() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -195,7 +195,7 @@ fn interlaced_rgba_8_should_be_palette_8() { fn interlaced_rgba_16_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -212,7 +212,7 @@ fn interlaced_rgba_16_should_be_palette_4() { fn interlaced_rgba_8_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -229,7 +229,7 @@ fn interlaced_rgba_8_should_be_palette_4() { fn interlaced_rgba_16_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -246,7 +246,7 @@ fn interlaced_rgba_16_should_be_palette_2() { fn interlaced_rgba_8_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -263,7 +263,7 @@ fn interlaced_rgba_8_should_be_palette_2() { fn interlaced_rgba_16_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -280,7 +280,7 @@ fn interlaced_rgba_16_should_be_palette_1() { fn interlaced_rgba_8_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -297,7 +297,7 @@ fn interlaced_rgba_8_should_be_palette_1() { fn interlaced_rgba_16_should_be_grayscale_alpha_16() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_grayscale_alpha_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -314,7 +314,7 @@ fn interlaced_rgba_16_should_be_grayscale_alpha_16() { fn interlaced_rgba_16_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -331,7 +331,7 @@ fn interlaced_rgba_16_should_be_grayscale_alpha_8() { fn interlaced_rgba_8_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -348,7 +348,7 @@ fn interlaced_rgba_8_should_be_grayscale_alpha_8() { fn interlaced_rgba_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -365,7 +365,7 @@ fn interlaced_rgba_16_should_be_grayscale_16() { fn interlaced_rgba_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_rgba_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -382,7 +382,7 @@ fn interlaced_rgba_16_should_be_grayscale_8() { fn interlaced_rgba_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_rgba_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -399,7 +399,7 @@ fn interlaced_rgba_8_should_be_grayscale_8() { fn interlaced_rgb_16_should_be_rgb_16() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_rgb_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -416,7 +416,7 @@ fn interlaced_rgb_16_should_be_rgb_16() { fn interlaced_rgb_16_should_be_rgb_8() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -433,7 +433,7 @@ fn interlaced_rgb_16_should_be_rgb_8() { fn interlaced_rgb_8_should_be_rgb_8() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -450,7 +450,7 @@ fn interlaced_rgb_8_should_be_rgb_8() { fn interlaced_rgb_16_should_be_palette_8() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -467,7 +467,7 @@ fn interlaced_rgb_16_should_be_palette_8() { fn interlaced_rgb_8_should_be_palette_8() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -484,7 +484,7 @@ fn interlaced_rgb_8_should_be_palette_8() { fn interlaced_rgb_16_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -501,7 +501,7 @@ fn interlaced_rgb_16_should_be_palette_4() { fn interlaced_rgb_8_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -518,7 +518,7 @@ fn interlaced_rgb_8_should_be_palette_4() { fn interlaced_rgb_16_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -535,7 +535,7 @@ fn interlaced_rgb_16_should_be_palette_2() { fn interlaced_rgb_8_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -552,7 +552,7 @@ fn interlaced_rgb_8_should_be_palette_2() { fn interlaced_rgb_16_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -569,7 +569,7 @@ fn interlaced_rgb_16_should_be_palette_1() { fn interlaced_rgb_8_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -586,7 +586,7 @@ fn interlaced_rgb_8_should_be_palette_1() { fn interlaced_rgb_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -603,7 +603,7 @@ fn interlaced_rgb_16_should_be_grayscale_16() { fn interlaced_rgb_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_rgb_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -620,7 +620,7 @@ fn interlaced_rgb_16_should_be_grayscale_8() { fn interlaced_rgb_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_rgb_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -637,7 +637,7 @@ fn interlaced_rgb_8_should_be_grayscale_8() { fn interlaced_palette_8_should_be_palette_8() { let input = PathBuf::from("tests/files/interlaced_palette_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -654,7 +654,7 @@ fn interlaced_palette_8_should_be_palette_8() { fn interlaced_palette_8_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_palette_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -671,7 +671,7 @@ fn interlaced_palette_8_should_be_palette_4() { fn interlaced_palette_4_should_be_palette_4() { let input = PathBuf::from("tests/files/interlaced_palette_4_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -688,7 +688,7 @@ fn interlaced_palette_4_should_be_palette_4() { fn interlaced_palette_8_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_palette_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -705,7 +705,7 @@ fn interlaced_palette_8_should_be_palette_2() { fn interlaced_palette_4_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_palette_4_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -722,7 +722,7 @@ fn interlaced_palette_4_should_be_palette_2() { fn interlaced_palette_2_should_be_palette_2() { let input = PathBuf::from("tests/files/interlaced_palette_2_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -739,7 +739,7 @@ fn interlaced_palette_2_should_be_palette_2() { fn interlaced_palette_8_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_palette_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -756,7 +756,7 @@ fn interlaced_palette_8_should_be_palette_1() { fn interlaced_palette_4_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_palette_4_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -773,7 +773,7 @@ fn interlaced_palette_4_should_be_palette_1() { fn interlaced_palette_2_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_palette_2_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -790,7 +790,7 @@ fn interlaced_palette_2_should_be_palette_1() { fn interlaced_palette_1_should_be_palette_1() { let input = PathBuf::from("tests/files/interlaced_palette_1_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -808,7 +808,7 @@ fn interlaced_grayscale_alpha_16_should_be_grayscale_alpha_16() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_16_should_be_grayscale_alpha_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -826,7 +826,7 @@ fn interlaced_grayscale_alpha_16_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_16_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -844,7 +844,7 @@ fn interlaced_grayscale_alpha_8_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_8_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -862,7 +862,7 @@ fn interlaced_grayscale_alpha_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -880,7 +880,7 @@ fn interlaced_grayscale_alpha_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -897,7 +897,7 @@ fn interlaced_grayscale_alpha_16_should_be_grayscale_8() { fn interlaced_grayscale_alpha_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_alpha_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -914,7 +914,7 @@ fn interlaced_grayscale_alpha_8_should_be_grayscale_8() { fn interlaced_grayscale_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/interlaced_grayscale_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -931,7 +931,7 @@ fn interlaced_grayscale_16_should_be_grayscale_16() { fn interlaced_grayscale_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -948,7 +948,7 @@ fn interlaced_grayscale_16_should_be_grayscale_8() { fn interlaced_grayscale_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/interlaced_grayscale_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -965,7 +965,7 @@ fn interlaced_grayscale_8_should_be_grayscale_8() { fn interlaced_small_files() { let input = PathBuf::from("tests/files/interlaced_small_files.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -982,7 +982,7 @@ fn interlaced_small_files() { fn interlaced_odd_width() { let input = PathBuf::from("tests/files/interlaced_odd_width.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, diff --git a/tests/reduction.rs b/tests/reduction.rs index c4505d96..ab4b7535 100644 --- a/tests/reduction.rs +++ b/tests/reduction.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; fn get_opts(input: &Path) -> oxipng::Options { let mut options = oxipng::Options::default(); - options.out_file = input.with_extension("out.png").to_owned(); + options.out_file = Some(input.with_extension("out.png").to_owned()); options.verbosity = None; options.force = true; let mut filter = HashSet::new(); @@ -59,7 +59,7 @@ fn test_it_converts( fn rgba_16_should_be_rgba_16() { let input = PathBuf::from("tests/files/rgba_16_should_be_rgba_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -76,7 +76,7 @@ fn rgba_16_should_be_rgba_16() { fn rgba_16_should_be_rgba_8() { let input = PathBuf::from("tests/files/rgba_16_should_be_rgba_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -93,7 +93,7 @@ fn rgba_16_should_be_rgba_8() { fn rgba_8_should_be_rgba_8() { let input = PathBuf::from("tests/files/rgba_8_should_be_rgba_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -110,7 +110,7 @@ fn rgba_8_should_be_rgba_8() { fn rgba_16_should_be_rgb_16() { let input = PathBuf::from("tests/files/rgba_16_should_be_rgb_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -127,7 +127,7 @@ fn rgba_16_should_be_rgb_16() { fn rgba_16_should_be_rgb_8() { let input = PathBuf::from("tests/files/rgba_16_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -144,7 +144,7 @@ fn rgba_16_should_be_rgb_8() { fn rgba_8_should_be_rgb_8() { let input = PathBuf::from("tests/files/rgba_8_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -161,7 +161,7 @@ fn rgba_8_should_be_rgb_8() { fn rgba_16_should_be_palette_8() { let input = PathBuf::from("tests/files/rgba_16_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -178,7 +178,7 @@ fn rgba_16_should_be_palette_8() { fn rgba_8_should_be_palette_8() { let input = PathBuf::from("tests/files/rgba_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -195,7 +195,7 @@ fn rgba_8_should_be_palette_8() { fn rgba_16_should_be_palette_4() { let input = PathBuf::from("tests/files/rgba_16_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -212,7 +212,7 @@ fn rgba_16_should_be_palette_4() { fn rgba_8_should_be_palette_4() { let input = PathBuf::from("tests/files/rgba_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -229,7 +229,7 @@ fn rgba_8_should_be_palette_4() { fn rgba_16_should_be_palette_2() { let input = PathBuf::from("tests/files/rgba_16_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -246,7 +246,7 @@ fn rgba_16_should_be_palette_2() { fn rgba_8_should_be_palette_2() { let input = PathBuf::from("tests/files/rgba_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -263,7 +263,7 @@ fn rgba_8_should_be_palette_2() { fn rgba_16_should_be_palette_1() { let input = PathBuf::from("tests/files/rgba_16_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -280,7 +280,7 @@ fn rgba_16_should_be_palette_1() { fn rgba_8_should_be_palette_1() { let input = PathBuf::from("tests/files/rgba_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -297,7 +297,7 @@ fn rgba_8_should_be_palette_1() { fn rgba_16_should_be_grayscale_alpha_16() { let input = PathBuf::from("tests/files/rgba_16_should_be_grayscale_alpha_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -314,7 +314,7 @@ fn rgba_16_should_be_grayscale_alpha_16() { fn rgba_16_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/rgba_16_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -331,7 +331,7 @@ fn rgba_16_should_be_grayscale_alpha_8() { fn rgba_8_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/rgba_8_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -348,7 +348,7 @@ fn rgba_8_should_be_grayscale_alpha_8() { fn rgba_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/rgba_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -365,7 +365,7 @@ fn rgba_16_should_be_grayscale_16() { fn rgba_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/rgba_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -382,7 +382,7 @@ fn rgba_16_should_be_grayscale_8() { fn rgba_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/rgba_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -399,7 +399,7 @@ fn rgba_8_should_be_grayscale_8() { fn rgb_16_should_be_rgb_16() { let input = PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -416,7 +416,7 @@ fn rgb_16_should_be_rgb_16() { fn rgb_16_should_be_rgb_8() { let input = PathBuf::from("tests/files/rgb_16_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -433,7 +433,7 @@ fn rgb_16_should_be_rgb_8() { fn rgb_8_should_be_rgb_8() { let input = PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -450,7 +450,7 @@ fn rgb_8_should_be_rgb_8() { fn rgb_16_should_be_palette_8() { let input = PathBuf::from("tests/files/rgb_16_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -467,7 +467,7 @@ fn rgb_16_should_be_palette_8() { fn rgb_8_should_be_palette_8() { let input = PathBuf::from("tests/files/rgb_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -484,7 +484,7 @@ fn rgb_8_should_be_palette_8() { fn rgb_16_should_be_palette_4() { let input = PathBuf::from("tests/files/rgb_16_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -501,7 +501,7 @@ fn rgb_16_should_be_palette_4() { fn rgb_8_should_be_palette_4() { let input = PathBuf::from("tests/files/rgb_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -518,7 +518,7 @@ fn rgb_8_should_be_palette_4() { fn rgb_16_should_be_palette_2() { let input = PathBuf::from("tests/files/rgb_16_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -535,7 +535,7 @@ fn rgb_16_should_be_palette_2() { fn rgb_8_should_be_palette_2() { let input = PathBuf::from("tests/files/rgb_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -552,7 +552,7 @@ fn rgb_8_should_be_palette_2() { fn rgb_16_should_be_palette_1() { let input = PathBuf::from("tests/files/rgb_16_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -569,7 +569,7 @@ fn rgb_16_should_be_palette_1() { fn rgb_8_should_be_palette_1() { let input = PathBuf::from("tests/files/rgb_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -586,7 +586,7 @@ fn rgb_8_should_be_palette_1() { fn rgb_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/rgb_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -603,7 +603,7 @@ fn rgb_16_should_be_grayscale_16() { fn rgb_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/rgb_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -620,7 +620,7 @@ fn rgb_16_should_be_grayscale_8() { fn rgb_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/rgb_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -637,7 +637,7 @@ fn rgb_8_should_be_grayscale_8() { fn palette_8_should_be_palette_8() { let input = PathBuf::from("tests/files/palette_8_should_be_palette_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -654,7 +654,7 @@ fn palette_8_should_be_palette_8() { fn palette_8_should_be_palette_4() { let input = PathBuf::from("tests/files/palette_8_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -671,7 +671,7 @@ fn palette_8_should_be_palette_4() { fn palette_4_should_be_palette_4() { let input = PathBuf::from("tests/files/palette_4_should_be_palette_4.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -688,7 +688,7 @@ fn palette_4_should_be_palette_4() { fn palette_8_should_be_palette_2() { let input = PathBuf::from("tests/files/palette_8_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -705,7 +705,7 @@ fn palette_8_should_be_palette_2() { fn palette_4_should_be_palette_2() { let input = PathBuf::from("tests/files/palette_4_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -722,7 +722,7 @@ fn palette_4_should_be_palette_2() { fn palette_2_should_be_palette_2() { let input = PathBuf::from("tests/files/palette_2_should_be_palette_2.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -739,7 +739,7 @@ fn palette_2_should_be_palette_2() { fn palette_8_should_be_palette_1() { let input = PathBuf::from("tests/files/palette_8_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -756,7 +756,7 @@ fn palette_8_should_be_palette_1() { fn palette_4_should_be_palette_1() { let input = PathBuf::from("tests/files/palette_4_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -773,7 +773,7 @@ fn palette_4_should_be_palette_1() { fn palette_2_should_be_palette_1() { let input = PathBuf::from("tests/files/palette_2_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -790,7 +790,7 @@ fn palette_2_should_be_palette_1() { fn palette_1_should_be_palette_1() { let input = PathBuf::from("tests/files/palette_1_should_be_palette_1.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -807,7 +807,7 @@ fn palette_1_should_be_palette_1() { fn grayscale_alpha_16_should_be_grayscale_alpha_16() { let input = PathBuf::from("tests/files/grayscale_alpha_16_should_be_grayscale_alpha_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -824,7 +824,7 @@ fn grayscale_alpha_16_should_be_grayscale_alpha_16() { fn grayscale_alpha_16_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/grayscale_alpha_16_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -841,7 +841,7 @@ fn grayscale_alpha_16_should_be_grayscale_alpha_8() { fn grayscale_alpha_8_should_be_grayscale_alpha_8() { let input = PathBuf::from("tests/files/grayscale_alpha_8_should_be_grayscale_alpha_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -858,7 +858,7 @@ fn grayscale_alpha_8_should_be_grayscale_alpha_8() { fn grayscale_alpha_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/grayscale_alpha_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -875,7 +875,7 @@ fn grayscale_alpha_16_should_be_grayscale_16() { fn grayscale_alpha_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/grayscale_alpha_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -892,7 +892,7 @@ fn grayscale_alpha_16_should_be_grayscale_8() { fn grayscale_alpha_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/grayscale_alpha_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -909,7 +909,7 @@ fn grayscale_alpha_8_should_be_grayscale_8() { fn grayscale_16_should_be_grayscale_16() { let input = PathBuf::from("tests/files/grayscale_16_should_be_grayscale_16.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -926,7 +926,7 @@ fn grayscale_16_should_be_grayscale_16() { fn grayscale_16_should_be_grayscale_8() { let input = PathBuf::from("tests/files/grayscale_16_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -943,7 +943,7 @@ fn grayscale_16_should_be_grayscale_8() { fn grayscale_8_should_be_grayscale_8() { let input = PathBuf::from("tests/files/grayscale_8_should_be_grayscale_8.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -960,7 +960,7 @@ fn grayscale_8_should_be_grayscale_8() { fn small_files() { let input = PathBuf::from("tests/files/small_files.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -977,7 +977,7 @@ fn small_files() { fn palette_should_be_reduced_with_dupes() { let input = PathBuf::from("tests/files/palette_should_be_reduced_with_dupes.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -1010,7 +1010,7 @@ fn palette_should_be_reduced_with_dupes() { fn palette_should_be_reduced_with_unused() { let input = PathBuf::from("tests/files/palette_should_be_reduced_with_unused.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -1043,7 +1043,7 @@ fn palette_should_be_reduced_with_unused() { fn palette_should_be_reduced_with_both() { let input = PathBuf::from("tests/files/palette_should_be_reduced_with_both.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -1076,7 +1076,7 @@ fn palette_should_be_reduced_with_both() { fn rgba_16_reduce_alpha_black() { let input = PathBuf::from("tests/files/rgba_16_reduce_alpha_black.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1093,7 +1093,7 @@ fn rgba_16_reduce_alpha_black() { fn rgba_8_reduce_alpha_black() { let input = PathBuf::from("tests/files/rgba_8_reduce_alpha_black.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1110,7 +1110,7 @@ fn rgba_8_reduce_alpha_black() { fn grayscale_alpha_16_reduce_alpha_black() { let input = PathBuf::from("tests/files/grayscale_alpha_16_reduce_alpha_black.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1127,7 +1127,7 @@ fn grayscale_alpha_16_reduce_alpha_black() { fn grayscale_alpha_8_reduce_alpha_black() { let input = PathBuf::from("tests/files/grayscale_alpha_8_reduce_alpha_black.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1146,7 +1146,7 @@ fn rgba_16_reduce_alpha_white() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::White); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1165,7 +1165,7 @@ fn rgba_8_reduce_alpha_white() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::White); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1184,7 +1184,7 @@ fn grayscale_alpha_16_reduce_alpha_white() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::White); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1203,7 +1203,7 @@ fn grayscale_alpha_8_reduce_alpha_white() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::White); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1222,7 +1222,7 @@ fn rgba_16_reduce_alpha_down() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Down); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1241,7 +1241,7 @@ fn rgba_8_reduce_alpha_down() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Down); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1260,7 +1260,7 @@ fn grayscale_alpha_16_reduce_alpha_down() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Down); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1279,7 +1279,7 @@ fn grayscale_alpha_8_reduce_alpha_down() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Down); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1298,7 +1298,7 @@ fn rgba_16_reduce_alpha_up() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Up); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1317,7 +1317,7 @@ fn rgba_8_reduce_alpha_up() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Up); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1336,7 +1336,7 @@ fn grayscale_alpha_16_reduce_alpha_up() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Up); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1355,7 +1355,7 @@ fn grayscale_alpha_8_reduce_alpha_up() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Up); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1374,7 +1374,7 @@ fn rgba_16_reduce_alpha_left() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Left); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1393,7 +1393,7 @@ fn rgba_8_reduce_alpha_left() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Left); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1412,7 +1412,7 @@ fn grayscale_alpha_16_reduce_alpha_left() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Left); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1431,7 +1431,7 @@ fn grayscale_alpha_8_reduce_alpha_left() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Left); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1450,7 +1450,7 @@ fn rgba_16_reduce_alpha_right() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Right); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1469,7 +1469,7 @@ fn rgba_8_reduce_alpha_right() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Right); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1488,7 +1488,7 @@ fn grayscale_alpha_16_reduce_alpha_right() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Right); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -1507,7 +1507,7 @@ fn grayscale_alpha_8_reduce_alpha_right() { let mut opts = get_opts(&input); opts.alphas = HashSet::with_capacity(1); opts.alphas.insert(AlphaOptim::Right); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, diff --git a/tests/regression.rs b/tests/regression.rs index 77d91496..59d5e2f4 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; fn get_opts(input: &Path) -> oxipng::Options { let mut options = oxipng::Options::default(); - options.out_file = input.with_extension("out.png").to_owned(); + options.out_file = Some(input.with_extension("out.png").to_owned()); options.verbosity = None; options.force = true; let mut filter = HashSet::new(); @@ -58,7 +58,7 @@ fn test_it_converts( fn issue_29() { let input = PathBuf::from("tests/files/issue-29.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -76,7 +76,7 @@ fn issue_42() { let input = PathBuf::from("tests/files/issue_42.png"); let mut opts = get_opts(&input); opts.interlace = Some(1); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap(); @@ -109,7 +109,7 @@ fn issue_42() { fn issue_52_01() { let input = PathBuf::from("tests/files/issue-52-01.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -126,7 +126,7 @@ fn issue_52_01() { fn issue_52_02() { let input = PathBuf::from("tests/files/issue-52-02.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -143,7 +143,7 @@ fn issue_52_02() { fn issue_52_03() { let input = PathBuf::from("tests/files/issue-52-03.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -160,7 +160,7 @@ fn issue_52_03() { fn issue_52_04() { let input = PathBuf::from("tests/files/issue-52-04.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -177,7 +177,7 @@ fn issue_52_04() { fn issue_52_05() { let input = PathBuf::from("tests/files/issue-52-05.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -194,7 +194,7 @@ fn issue_52_05() { fn issue_52_06() { let input = PathBuf::from("tests/files/issue-52-06.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -211,7 +211,7 @@ fn issue_52_06() { fn issue_56() { let input = PathBuf::from("tests/files/issue-56.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -228,7 +228,7 @@ fn issue_56() { fn issue_58() { let input = PathBuf::from("tests/files/issue-58.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -245,7 +245,7 @@ fn issue_58() { fn issue_59() { let input = PathBuf::from("tests/files/issue-59.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -262,7 +262,7 @@ fn issue_59() { fn issue_60() { let input = PathBuf::from("tests/files/issue-60.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -279,7 +279,7 @@ fn issue_60() { fn issue_80() { let input = PathBuf::from("tests/files/issue-80.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -296,7 +296,7 @@ fn issue_80() { fn issue_82() { let input = PathBuf::from("tests/files/issue-82.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -313,7 +313,7 @@ fn issue_82() { fn issue_89() { let input = PathBuf::from("tests/files/issue-89.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -330,7 +330,7 @@ fn issue_89() { fn issue_92_filter_0() { let input = PathBuf::from("tests/files/issue-92.png"); let opts = get_opts(&input); - let output = opts.out_file.clone(); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input, @@ -350,8 +350,8 @@ fn issue_92_filter_5() { let mut filter = HashSet::new(); filter.insert(5); opts.filter = filter; - opts.out_file = input.with_extension("-f5-out.png").to_owned(); - let output = opts.out_file.clone(); + opts.out_file = Some(input.with_extension("-f5-out.png").to_owned()); + let output = opts.out_file.clone().unwrap(); test_it_converts( &input,