Skip to content

Commit

Permalink
Fix bug with fast flag and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 committed Jul 10, 2023
1 parent 40ec5b3 commit 85b1fc2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub struct Options {
///
/// `Some(x)` will change the file to interlacing mode `x`.
///
/// Default: `Some(None)`
/// Default: `Some(Interlacing::None)`
pub interlace: Option<Interlacing>,
/// Whether to allow transparent pixels to be altered to improve compression.
pub optimize_alpha: bool,
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ fn parse_opts_into_struct(

opts.scale_16 = matches.get_flag("scale16");

opts.fast_evaluation = matches.get_flag("fast");
// The default value for fast depends on the preset - make sure we don't change when not provided
if matches.get_flag("fast") {
opts.fast_evaluation = matches.get_flag("fast");
}

opts.backup = matches.get_flag("backup");

Expand Down
Binary file modified tests/files/interlaced_palette_8_should_be_grayscale_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/files/palette_8_should_be_grayscale_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tests/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::ops::Deref;
use std::path::Path;
use std::path::PathBuf;

const GRAYSCALE: u8 = 0;
const RGB: u8 = 2;
const INDEXED: u8 = 3;
const RGBA: u8 = 6;
Expand Down Expand Up @@ -597,7 +598,7 @@ fn fix_errors() {
}
};

assert_eq!(png.raw.ihdr.color_type.png_header_code(), INDEXED);
assert_eq!(png.raw.ihdr.color_type.png_header_code(), GRAYSCALE);
assert_eq!(png.raw.ihdr.bit_depth, BitDepth::Eight);

// Cannot check if pixels are equal because image crate cannot read corrupt (input) PNGs
Expand Down
1 change: 1 addition & 0 deletions tests/interlaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn get_opts(input: &Path) -> (OutFile, oxipng::Options) {
let mut options = oxipng::Options {
force: true,
fast_evaluation: false,
interlace: None,
..Default::default()
};
let mut filter = IndexSet::new();
Expand Down

0 comments on commit 85b1fc2

Please sign in to comment.