463 {
464 options opts;
465
466 if (!parse_arguments(argc, argv, opts)) {
467 std::cout << R"(
468 ____ ____ __ __ ____ ___ _ ___ __
469 | _ \ / ___| \/ | / ___/ _ \| \ | \ \ / /
470 | | | | | | |\/| | | | | | | | \| |\ \ / /
471 | |_| | |___| | | | | |__| |_| | |\ | \ V /
472 |____/ \____|_| |_| \____\___/|_| \_| \_/
473
474 DICOM Transfer Syntax Converter
475)" << "\n";
476 print_usage(argv[0]);
477 return 1;
478 }
479
480 if (opts.list_syntaxes) {
481 list_supported_syntaxes();
482 return 0;
483 }
484
485
486 if (!opts.quiet) {
487 std::cout << R"(
488 ____ ____ __ __ ____ ___ _ ___ __
489 | _ \ / ___| \/ | / ___/ _ \| \ | \ \ / /
490 | | | | | | |\/| | | | | | | | \| |\ \ / /
491 | |_| | |___| | | | | |__| |_| | |\ | \ V /
492 |____/ \____|_| |_| \____\___/|_| \_| \_/
493
494 DICOM Transfer Syntax Converter
495)" << "\n";
496 }
497
498
499 if (!std::filesystem::exists(opts.input_path)) {
500 std::cerr << "Error: Input path does not exist: " << opts.input_path.string() << "\n";
501 return 2;
502 }
503
505 if (!opts.quiet) {
506 std::cout << "Target Transfer Syntax: " << target_ts.name() << "\n";
507 std::cout << " UID: " << target_ts.uid() << "\n\n";
508 }
509
510 conversion_stats stats;
511 auto start_time = std::chrono::steady_clock::now();
512
513 if (std::filesystem::is_directory(opts.input_path)) {
514
515 if (!std::filesystem::exists(opts.output_path)) {
516 std::filesystem::create_directories(opts.output_path);
517 }
518
519 if (!opts.quiet) {
520 std::cout << "Processing directory: " << opts.input_path.string() << "\n";
521 if (opts.recursive) {
522 std::cout << "Mode: Recursive\n\n";
523 }
524 }
525
526 process_directory(opts.input_path, opts.output_path, opts, stats);
527 } else {
528
529 ++stats.total_files;
530
531 if (convert_file(opts.input_path, opts.output_path, opts)) {
532 ++stats.success_count;
533 } else {
534 ++stats.error_count;
535 }
Represents a DICOM Transfer Syntax.