Skip to content

Commit

Permalink
fix: explicit filename extension override (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston authored Nov 3, 2023
1 parent 0f25654 commit e211ba8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions catwalk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ macro_rules! open_image {
let mut rel_path = $args.directory.clone().unwrap_or_default();
let path = $path.unwrap_or_default();
rel_path.push(path.clone());
match $args.extension {
Extension::Webp => {
rel_path.set_extension("webp");
}
Extension::Png => {
rel_path.set_extension("png");
// set the `--ext` file extension unless the filenames are explicitly given
if path == std::path::PathBuf::default() {
match $args.extension {
Extension::Webp => {
rel_path.set_extension("webp");
}
Extension::Png => {
rel_path.set_extension("png");
}
}
}
Image::<Rgba>::open(&rel_path)
Expand Down

0 comments on commit e211ba8

Please sign in to comment.