|
22 | 22 |
|
23 | 23 | #include <iostream>
|
24 | 24 | #include <iomanip>
|
| 25 | +#include <iterator> |
25 | 26 | #include <string>
|
26 | 27 | #include <QApplication>
|
27 | 28 | #include <QTranslator>
|
@@ -72,27 +73,44 @@ struct CoutProgressIndicator : public ProgressIndicator {
|
72 | 73 |
|
73 | 74 | list<LoadOptions> Launcher::getBracketedSets() {
|
74 | 75 | list<LoadOptions> result;
|
75 |
| - list<pair<ImageIO::QDateInterval, QString>> dateNames; |
76 |
| - for (QString & name : generalOptions.fileNames) { |
77 |
| - ImageIO::QDateInterval interval = ImageIO::getImageCreationInterval(name); |
78 |
| - if (interval.start.isValid()) { |
79 |
| - dateNames.emplace_back(interval, name); |
80 |
| - } else { |
81 |
| - // We cannot get time information, process it alone |
82 |
| - result.push_back(generalOptions); |
83 |
| - result.back().fileNames.clear(); |
84 |
| - result.back().fileNames.push_back(name); |
| 76 | + if (generalOptions.imagesPerBracket > 0) { |
| 77 | + if (generalOptions.fileNames % generalOptions.imagesPerBracket != 0) { |
| 78 | + throw std::logic_error("Number of files not a multiple of number per bracketed set (-i)."); |
85 | 79 | }
|
86 |
| - } |
87 |
| - dateNames.sort(); |
88 |
| - ImageIO::QDateInterval lastInterval; |
89 |
| - for (auto & dateName : dateNames) { |
90 |
| - if (lastInterval.start.isNull() || lastInterval.difference(dateName.first) > generalOptions.batchGap) { |
91 |
| - result.push_back(generalOptions); |
92 |
| - result.back().fileNames.clear(); |
| 80 | + |
| 81 | + while(!generalOptions.fileNames.empty()) { |
| 82 | + LoadOptions opt = generalOptions; |
| 83 | + auto oIt = opt.fileNames.begin(); |
| 84 | + auto goIt = generalOptions.fileNames.begin(); |
| 85 | + std::advance(oIt, generalOptions.imagesPerBracket); |
| 86 | + std::advance(goIt, generalOptions.imagesPerBracket); |
| 87 | + opt.fileNames.erase(oIt, opt.fileNames.end()); |
| 88 | + generalOptions.fileNames.erase(generalOptions.fileNames.begin(), goIt); |
| 89 | + result.push_back(opt); |
| 90 | + } |
| 91 | + } else { |
| 92 | + list<pair<ImageIO::QDateInterval, QString>> dateNames; |
| 93 | + for (QString & name : generalOptions.fileNames) { |
| 94 | + ImageIO::QDateInterval interval = ImageIO::getImageCreationInterval(name); |
| 95 | + if (interval.start.isValid()) { |
| 96 | + dateNames.emplace_back(interval, name); |
| 97 | + } else { |
| 98 | + // We cannot get time information, process it alone |
| 99 | + result.push_back(generalOptions); |
| 100 | + result.back().fileNames.clear(); |
| 101 | + result.back().fileNames.push_back(name); |
| 102 | + } |
| 103 | + } |
| 104 | + dateNames.sort(); |
| 105 | + ImageIO::QDateInterval lastInterval; |
| 106 | + for (auto & dateName : dateNames) { |
| 107 | + if (lastInterval.start.isNull() || lastInterval.difference(dateName.first) > generalOptions.batchGap) { |
| 108 | + result.push_back(generalOptions); |
| 109 | + result.back().fileNames.clear(); |
| 110 | + } |
| 111 | + result.back().fileNames.push_back(dateName.second); |
| 112 | + lastInterval = dateName.first; |
93 | 113 | }
|
94 |
| - result.back().fileNames.push_back(dateName.second); |
95 |
| - lastInterval = dateName.first; |
96 | 114 | }
|
97 | 115 | int setNum = 0;
|
98 | 116 | for (auto & i : result) {
|
@@ -174,6 +192,15 @@ void Launcher::parseCommandLine() {
|
174 | 192 | generalOptions.crop = false;
|
175 | 193 | } else if (string("--batch") == argv[i] || string("-B") == argv[i]) {
|
176 | 194 | generalOptions.batch = true;
|
| 195 | + } else if (string("-i") == argv[i]) { |
| 196 | + if(++i < argc) { |
| 197 | + try { |
| 198 | + int value = stoi(argv[i]); |
| 199 | + generalOptions.imagesPerBracket = value; |
| 200 | + } catch(std::invalid_argument & e) { |
| 201 | + cerr << tr("Invalid %1 parameter, falling back to interval-based bracketing set creation.").arg(argv[i - 1]) << endl; |
| 202 | + } |
| 203 | + } |
177 | 204 | } else if (string("--single") == argv[i]) {
|
178 | 205 | generalOptions.withSingles = true;
|
179 | 206 | } else if (string("--help") == argv[i]) {
|
@@ -257,6 +284,8 @@ void Launcher::showHelp() {
|
257 | 284 | cout << " " << "-a " << tr("Calculates the output file name as") << " %id[-1]/%iF[0]-%in[-1].dng." << endl;
|
258 | 285 | cout << " " << "-B|--batch " << tr("Batch mode: Input images are automatically grouped into bracketed sets,") << endl;
|
259 | 286 | cout << " " << " " << tr("by comparing the creation time. Implies -a if no output file name is given.") << endl;
|
| 287 | + cout << " " << "-i NUM_IMAGES " << tr("Fixed number of images per bracket set. use together with -B.") << endl; |
| 288 | + cout << " " << " " << tr("Creation time will be ignored.") << endl; |
260 | 289 | cout << " " << "-g gap " << tr("Batch gap, maximum difference in seconds between two images of the same set.") << endl;
|
261 | 290 | cout << " " << "--single " << tr("Include single images in batch mode (the default is to skip them.)") << endl;
|
262 | 291 | cout << " " << "-b BPS " << tr("Bits per sample, can be 16, 24 or 32.") << endl;
|
|
0 commit comments