Skip to content

Commit

Permalink
feat: add recursive flag for searching dir recursively for all images
Browse files Browse the repository at this point in the history
  • Loading branch information
rymdtian committed Apr 9, 2024
1 parent cd02c5e commit 18d307c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ struct Cli {
/// Directory to save the splixed images in. Default: `./splixed-images`.
#[arg(short = 'o', long = "output-dir")]
output_dir: Option<PathBuf>,

/// Enable recursive search for images in specified directory.
#[arg(short = 'R', long)]
recursive: bool,
}

/// Validates the provided command-line arguments.
Expand Down Expand Up @@ -242,8 +246,13 @@ fn main() {
let rows = cli.rows.unwrap_or(vec![1]);
let cols = cli.cols.unwrap_or(vec![1]);
let output_directory = cli.output_dir.unwrap_or(PathBuf::from("splixed-images"));
let entries = if cli.recursive {
WalkDir::new(&img_dir)
} else {
WalkDir::new(&img_dir).max_depth(1)
};

for entry in WalkDir::new(&img_dir) {
for entry in entries {
match entry {
Ok(entry) => {
if let Ok(img) = image::open(entry.path()) {
Expand Down

0 comments on commit 18d307c

Please sign in to comment.