Skip to content

Commit d60fb27

Browse files
authored
fix: avoid unwanted file extension changes (#1257)
1 parent c7ccafb commit d60fb27

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/cli/main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,15 @@ bool save_results(const SDCliParams& cli_params,
394394

395395
fs::path base_path = out_path;
396396
fs::path ext = out_path.has_extension() ? out_path.extension() : fs::path{};
397-
if (!ext.empty())
398-
base_path.replace_extension();
399397

400398
std::string ext_lower = ext.string();
401399
std::transform(ext_lower.begin(), ext_lower.end(), ext_lower.begin(), ::tolower);
402400
bool is_jpg = (ext_lower == ".jpg" || ext_lower == ".jpeg" || ext_lower == ".jpe");
401+
if (!ext.empty()) {
402+
if (is_jpg || ext_lower == ".png") {
403+
base_path.replace_extension();
404+
}
405+
}
403406

404407
int output_begin_idx = cli_params.output_begin_idx;
405408
if (output_begin_idx < 0) {

0 commit comments

Comments
 (0)