Add --algorithm and --overwrite flags to CLI
Support resize algorithm selection (lanczos3/catmullrom/bilinear/nearest) and overwrite behavior (auto-rename/overwrite/skip) in the CLI process command, matching the GUI functionality.
This commit is contained in:
@@ -82,6 +82,14 @@ enum Commands {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
rename_template: Option<String>,
|
rename_template: Option<String>,
|
||||||
|
|
||||||
|
/// Resize algorithm (lanczos3, catmullrom, bilinear, nearest)
|
||||||
|
#[arg(long, default_value = "lanczos3")]
|
||||||
|
algorithm: String,
|
||||||
|
|
||||||
|
/// Overwrite behavior (auto-rename, overwrite, skip)
|
||||||
|
#[arg(long, default_value = "auto-rename")]
|
||||||
|
overwrite: String,
|
||||||
|
|
||||||
/// Include subdirectories
|
/// Include subdirectories
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
recursive: bool,
|
recursive: bool,
|
||||||
@@ -168,6 +176,8 @@ fn main() {
|
|||||||
rename_prefix,
|
rename_prefix,
|
||||||
rename_suffix,
|
rename_suffix,
|
||||||
rename_template,
|
rename_template,
|
||||||
|
algorithm,
|
||||||
|
overwrite,
|
||||||
recursive,
|
recursive,
|
||||||
} => {
|
} => {
|
||||||
cmd_process(CmdProcessArgs {
|
cmd_process(CmdProcessArgs {
|
||||||
@@ -186,6 +196,8 @@ fn main() {
|
|||||||
rename_prefix,
|
rename_prefix,
|
||||||
rename_suffix,
|
rename_suffix,
|
||||||
rename_template,
|
rename_template,
|
||||||
|
algorithm,
|
||||||
|
overwrite,
|
||||||
recursive,
|
recursive,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -225,6 +237,8 @@ struct CmdProcessArgs {
|
|||||||
rename_prefix: Option<String>,
|
rename_prefix: Option<String>,
|
||||||
rename_suffix: Option<String>,
|
rename_suffix: Option<String>,
|
||||||
rename_template: Option<String>,
|
rename_template: Option<String>,
|
||||||
|
algorithm: String,
|
||||||
|
overwrite: String,
|
||||||
recursive: bool,
|
recursive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +325,19 @@ fn cmd_process(args: CmdProcessArgs) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
job.resize_algorithm = match args.algorithm.to_lowercase().as_str() {
|
||||||
|
"catmullrom" | "catmull-rom" => ResizeAlgorithm::CatmullRom,
|
||||||
|
"bilinear" => ResizeAlgorithm::Bilinear,
|
||||||
|
"nearest" => ResizeAlgorithm::Nearest,
|
||||||
|
_ => ResizeAlgorithm::Lanczos3,
|
||||||
|
};
|
||||||
|
|
||||||
|
job.overwrite_behavior = match args.overwrite.to_lowercase().as_str() {
|
||||||
|
"overwrite" | "always" => OverwriteBehavior::Overwrite,
|
||||||
|
"skip" => OverwriteBehavior::Skip,
|
||||||
|
_ => OverwriteBehavior::AutoRename,
|
||||||
|
};
|
||||||
|
|
||||||
for file in &source_files {
|
for file in &source_files {
|
||||||
job.add_source(file);
|
job.add_source(file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user