Struct dither::prelude::Opt [−][src]
pub struct Opt { pub verbose: bool, pub input: PathBuf, pub bit_depth: u8, pub output: Option<PathBuf>, pub ditherer: Ditherer<'static>, pub color_mode: Mode, }
Command-line interface & arguments. See clap.
Fields
verbose: bool
Provide verbose debug information. Default is false.
input: PathBuf
Input file. Supported file types:
PNG
JPEG
GIF
BMP
ICO
TIFF
bit_depth: u8
Color depth. Must be between 1 and 8. See create_quantize_n_bits_func and [create_convert_quantized_to_palette_func][crate::create_convert_quantized_to_palette_func]
output: Option<PathBuf>
Output file: will be written to as a .png or .jpg (inferred from file extension). If left empty, a default output path will be created: see Opt::output_path
ditherer: Ditherer<'static>
Ditherering algorithm to use. Options are
- “floyd” (default)
- “atkinson”
- “stucki”,
- “burkes”
- “jarvis”
- “sierra3”
color_mode: Mode
Color mode to use. Options are
- bw => grayscale with the specified bit depth. (default)
- color => color mode with the specified bit depth.
- cga => load the cga palette. equivalent to “cga.plt”.
- crayon => load the crayon palette. equivalent to “crayon.plt”
- $COLOR => single-color mode. options are
- $FILENAME“ => load palette from file, listed as line-separated RGB values. see “cga.plt” and the readme for more information on palette files.
Implementations
impl Opt
[src]
impl Opt
[src]pub fn input_path<'a>(&'a self) -> Result<PathBuf>
[src]
the canonicalized input path
pub fn output_path<'a>(&'a self) -> Result<Cow<'a, Path>>
[src]
the actual output path. if opts.output exists, this is that, otherwise, this is
"{base}_dithered_{dither}_{color}_{depth}.png"
,
where base is the canonicalized input path, stripped of it’s extension.
$dither bunny.png --color=color --dither=atkinson --depth=2
will save to bunny_atkinson_c_2.png
let mut opt = Opt::default(); opt.bit_depth=1; opt.input = PathBuf::from("bunny.png".to_string()); let got_path = opt.output_path().unwrap(); assert_eq!("bunny_dithered_floyd_bw_1.png", Path::file_name(got_path.as_ref().as_ref()).unwrap().to_string_lossy());
Trait Implementations
impl Clap for Opt
[src]
impl Clap for Opt
[src]pub fn parse() -> Self
[src]
pub fn try_parse() -> Result<Self, Error>
[src]
pub fn parse_from<I, T>(itr: I) -> Self where
T: Into<OsString> + Clone,
I: IntoIterator<Item = T>,
[src]
T: Into<OsString> + Clone,
I: IntoIterator<Item = T>,
pub fn try_parse_from<I, T>(itr: I) -> Result<Self, Error> where
T: Into<OsString> + Clone,
I: IntoIterator<Item = T>,
[src]
T: Into<OsString> + Clone,
I: IntoIterator<Item = T>,
impl FromArgMatches for Opt
[src]
impl FromArgMatches for Opt
[src]fn from_arg_matches(matches: &ArgMatches) -> Self
[src]
impl StructuralPartialEq for Opt
[src]
impl StructuralPartialEq for Opt
[src]Auto Trait Implementations
impl RefUnwindSafe for Opt
impl RefUnwindSafe for Opt
impl UnwindSafe for Opt
impl UnwindSafe for Opt