parent
9de0eeaf51
commit
aa8b58628e
1 changed files with 42 additions and 14 deletions
56
src/lib.rs
56
src/lib.rs
|
|
@ -42,7 +42,8 @@ mod reduction;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
/// Options controlling the output of the `optimize` function
|
/// Options controlling the output of the `optimize` function
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
/// Whether the input file should be backed up before writing the output
|
/// Whether the input file should be backed up before writing the output.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub backup: bool,
|
pub backup: bool,
|
||||||
/// Path to write the output file to. If not set, the application will default to
|
/// Path to write the output file to. If not set, the application will default to
|
||||||
|
|
@ -51,82 +52,109 @@ pub struct Options {
|
||||||
/// Used only in CLI interface
|
/// Used only in CLI interface
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub out_dir: Option<PathBuf>,
|
pub out_dir: Option<PathBuf>,
|
||||||
/// Write to stdout instead of a file
|
/// Write to stdout instead of a file.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub stdout: bool,
|
pub stdout: bool,
|
||||||
/// Attempt to fix errors when decoding the input file rather than returning an `Err`
|
/// Attempt to fix errors when decoding the input file rather than returning an `Err`.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub fix_errors: bool,
|
pub fix_errors: bool,
|
||||||
/// Don't actually write any output, just calculate the best results
|
/// Don't actually write any output, just calculate the best results.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub pretend: bool,
|
pub pretend: bool,
|
||||||
/// Used only in CLI interface
|
/// Used only in CLI interface
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub recursive: bool,
|
pub recursive: bool,
|
||||||
/// Overwrite existing output files
|
/// Overwrite existing output files.
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub clobber: bool,
|
pub clobber: bool,
|
||||||
/// Create new output files if they don't exist
|
/// Create new output files if they don't exist.
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub create: bool,
|
pub create: bool,
|
||||||
/// Write to output even if there was no improvement in compression
|
/// Write to output even if there was no improvement in compression.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub force: bool,
|
pub force: bool,
|
||||||
/// Ensure the output file has the same permissions as the input file
|
/// Ensure the output file has the same permissions as the input file.
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub preserve_attrs: bool,
|
pub preserve_attrs: bool,
|
||||||
/// How verbose the console logging should be (`None` for quiet, `Some(0)` for normal, `Some(1)` for verbose)
|
/// How verbose the console logging should be (`None` for quiet, `Some(0)` for normal, `Some(1)` for verbose)
|
||||||
|
///
|
||||||
/// Default: `Some(0)`
|
/// Default: `Some(0)`
|
||||||
pub verbosity: Option<u8>,
|
pub verbosity: Option<u8>,
|
||||||
/// Which filters to try on the file (0-5)
|
/// Which filters to try on the file (0-5)
|
||||||
|
///
|
||||||
/// Default: `0,5`
|
/// Default: `0,5`
|
||||||
pub filter: HashSet<u8>,
|
pub filter: HashSet<u8>,
|
||||||
/// Whether to change the interlacing type of the file
|
/// Whether to change the interlacing type of the file.
|
||||||
/// `None` will not change the current interlacing type
|
///
|
||||||
/// `Some(x)` will change the file to interlacing mode `x`
|
/// `None` will not change the current interlacing type.
|
||||||
|
///
|
||||||
|
/// `Some(x)` will change the file to interlacing mode `x`.
|
||||||
|
///
|
||||||
/// Default: `None`
|
/// Default: `None`
|
||||||
pub interlace: Option<u8>,
|
pub interlace: Option<u8>,
|
||||||
/// Which zlib compression levels to try on the file (1-9)
|
/// Which zlib compression levels to try on the file (1-9)
|
||||||
|
///
|
||||||
/// Default: `9`
|
/// Default: `9`
|
||||||
pub compression: HashSet<u8>,
|
pub compression: HashSet<u8>,
|
||||||
/// Which zlib memory levels to try on the file (1-9)
|
/// Which zlib memory levels to try on the file (1-9)
|
||||||
|
///
|
||||||
/// Default: `9`
|
/// Default: `9`
|
||||||
pub memory: HashSet<u8>,
|
pub memory: HashSet<u8>,
|
||||||
/// Which zlib compression strategies to try on the file (0-3)
|
/// Which zlib compression strategies to try on the file (0-3)
|
||||||
|
///
|
||||||
/// Default: `0-3`
|
/// Default: `0-3`
|
||||||
pub strategies: HashSet<u8>,
|
pub strategies: HashSet<u8>,
|
||||||
/// Window size to use when compressing the file, as `2^window` bytes
|
/// Window size to use when compressing the file, as `2^window` bytes.
|
||||||
/// Doesn't affect compression but may affect speed and memory usage
|
///
|
||||||
/// 8-15 are valid values
|
/// Doesn't affect compression but may affect speed and memory usage.
|
||||||
|
/// 8-15 are valid values.
|
||||||
|
///
|
||||||
/// Default: `15`
|
/// Default: `15`
|
||||||
pub window: u8,
|
pub window: u8,
|
||||||
/// Alpha filtering strategies to use
|
/// Alpha filtering strategies to use
|
||||||
pub alphas: HashSet<colors::AlphaOptim>,
|
pub alphas: HashSet<colors::AlphaOptim>,
|
||||||
/// Whether to attempt bit depth reduction
|
/// Whether to attempt bit depth reduction
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub bit_depth_reduction: bool,
|
pub bit_depth_reduction: bool,
|
||||||
/// Whether to attempt color type reduction
|
/// Whether to attempt color type reduction
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub color_type_reduction: bool,
|
pub color_type_reduction: bool,
|
||||||
/// Whether to attempt palette reduction
|
/// Whether to attempt palette reduction
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub palette_reduction: bool,
|
pub palette_reduction: bool,
|
||||||
/// Whether to perform IDAT recoding
|
/// Whether to perform IDAT recoding
|
||||||
|
///
|
||||||
/// If any type of reduction is performed, IDAT recoding will be performed
|
/// If any type of reduction is performed, IDAT recoding will be performed
|
||||||
/// regardless of this setting
|
/// regardless of this setting
|
||||||
|
///
|
||||||
/// Default: `true`
|
/// Default: `true`
|
||||||
pub idat_recoding: bool,
|
pub idat_recoding: bool,
|
||||||
/// Which headers to strip from the PNG file, if any
|
/// Which headers to strip from the PNG file, if any
|
||||||
|
///
|
||||||
/// Default: `None`
|
/// Default: `None`
|
||||||
pub strip: Headers,
|
pub strip: Headers,
|
||||||
/// Which DEFLATE algorithm to use
|
/// Which DEFLATE algorithm to use
|
||||||
|
///
|
||||||
/// Default: `Zlib`
|
/// Default: `Zlib`
|
||||||
pub deflate: Deflaters,
|
pub deflate: Deflaters,
|
||||||
/// Whether to use heuristics to pick the best filter and compression
|
/// Whether to use heuristics to pick the best filter and compression
|
||||||
|
///
|
||||||
/// Intended for use with `-o 1` from the CLI interface
|
/// Intended for use with `-o 1` from the CLI interface
|
||||||
|
///
|
||||||
/// Default: `false`
|
/// Default: `false`
|
||||||
pub use_heuristics: bool,
|
pub use_heuristics: bool,
|
||||||
/// Number of threads to use
|
/// Number of threads to use
|
||||||
|
///
|
||||||
/// Default: 1.5x CPU cores, rounded down
|
/// Default: 1.5x CPU cores, rounded down
|
||||||
pub threads: usize,
|
pub threads: usize,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue