This patch adds a new option “-i” which accepts the number per bracket set, so in your case 3. Or 5.
I do not (yet) check if that number divides the number of images passed.
diff --git a/src/Launcher.cpp b/src/Launcher.cpp
index b188d79..0539b46 100644
--- a/src/Launcher.cpp
+++ b/src/Launcher.cpp
@@ -22,6 +22,7 @@
#include <iostream>
#include <iomanip>
+#include <iterator>
#include <string>
#include <QApplication>
#include <QTranslator>
@@ -72,27 +73,42 @@ struct CoutProgressIndicator : public ProgressIndicator {
list<LoadOptions> Launcher::getBracketedSets() {
list<LoadOptions> result;
- list<pair<ImageIO::QDateInterval, QString>> dateNames;
- for (QString & name : generalOptions.fileNames) {
- ImageIO::QDateInterval interval = ImageIO::getImageCreationInterval(name);
- if (interval.start.isValid()) {
- dateNames.emplace_back(interval, name);
- } else {
- // We cannot get time information, process it alone
- result.push_back(generalOptions);
- result.back().fileNames.clear();
- result.back().fileNames.push_back(name);
+ if(generalOptions.imagesPerBracket > 0) {
+ cout << "creating sets with " << generalOptions.imagesPerBracket << " images per set." << endl;
+ while(!generalOptions.fileNames.empty()) {
+ // for the moment assume that filenames.size() % imagesPerBracket ==0
+ LoadOptions opt = generalOptions;
+ auto oIt = opt.fileNames.begin();
+ auto goIt = generalOptions.fileNames.begin();
+ std::advance(oIt, generalOptions.imagesPerBracket);
+ std::advance(goIt, generalOptions.imagesPerBracket);
+ opt.fileNames.erase(oIt, opt.fileNames.end());
+ generalOptions.fileNames.erase(generalOptions.fileNames.begin(), goIt);
+ result.push_back(opt);
}
- }
- dateNames.sort();
- ImageIO::QDateInterval lastInterval;
- for (auto & dateName : dateNames) {
- if (lastInterval.start.isNull() || lastInterval.difference(dateName.first) > generalOptions.batchGap) {
- result.push_back(generalOptions);
- result.back().fileNames.clear();
+ } else {
+ list<pair<ImageIO::QDateInterval, QString>> dateNames;
+ for (QString & name : generalOptions.fileNames) {
+ ImageIO::QDateInterval interval = ImageIO::getImageCreationInterval(name);
+ if (interval.start.isValid()) {
+ dateNames.emplace_back(interval, name);
+ } else {
+ // We cannot get time information, process it alone
+ result.push_back(generalOptions);
+ result.back().fileNames.clear();
+ result.back().fileNames.push_back(name);
+ }
+ }
+ dateNames.sort();
+ ImageIO::QDateInterval lastInterval;
+ for (auto & dateName : dateNames) {
+ if (lastInterval.start.isNull() || lastInterval.difference(dateName.first) > generalOptions.batchGap) {
+ result.push_back(generalOptions);
+ result.back().fileNames.clear();
+ }
+ result.back().fileNames.push_back(dateName.second);
+ lastInterval = dateName.first;
}
- result.back().fileNames.push_back(dateName.second);
- lastInterval = dateName.first;
}
int setNum = 0;
for (auto & i : result) {
@@ -174,6 +190,15 @@ void Launcher::parseCommandLine() {
generalOptions.crop = false;
} else if (string("--batch") == argv[i] || string("-B") == argv[i]) {
generalOptions.batch = true;
+ } else if (string("-i") == argv[i]) {
+ if(++i < argc) {
+ try {
+ int value = stoi(argv[i]);
+ generalOptions.imagesPerBracket = value;
+ } catch(std::invalid_argument & e) {
+ cerr << tr("Invalid %1 parameter, falling back to interval-based bracketing set creation.").arg(argv[i - 1]) << endl;
+ }
+ }
} else if (string("--single") == argv[i]) {
generalOptions.withSingles = true;
} else if (string("--help") == argv[i]) {
@@ -257,6 +282,8 @@ void Launcher::showHelp() {
cout << " " << "-a " << tr("Calculates the output file name as") << " %id[-1]/%iF[0]-%in[-1].dng." << endl;
cout << " " << "-B|--batch " << tr("Batch mode: Input images are automatically grouped into bracketed sets,") << endl;
cout << " " << " " << tr("by comparing the creation time. Implies -a if no output file name is given.") << endl;
+ cout << " " << "-i NUM_IMAGES " << tr("Fixed number of images per bracket set. use together with -B.") << endl;
+ cout << " " << " " << tr("Creation time will be ignored.") << endl;
cout << " " << "-g gap " << tr("Batch gap, maximum difference in seconds between two images of the same set.") << endl;
cout << " " << "--single " << tr("Include single images in batch mode (the default is to skip them.)") << endl;
cout << " " << "-b BPS " << tr("Bits per sample, can be 16, 24 or 32.") << endl;
diff --git a/src/LoadSaveOptions.hpp b/src/LoadSaveOptions.hpp
index 5c3db3d..7d6fce0 100644
--- a/src/LoadSaveOptions.hpp
+++ b/src/LoadSaveOptions.hpp
@@ -35,9 +35,10 @@ struct LoadOptions {
bool useCustomWl;
uint16_t customWl;
bool batch;
+ int imagesPerBracket;
double batchGap;
bool withSingles;
- LoadOptions() : align(true), crop(true), useCustomWl(false), customWl(16383), batch(false), batchGap(2.0),
+ LoadOptions() : align(true), crop(true), useCustomWl(false), customWl(16383), batch(false), imagesPerBracket(-1), batchGap(2.0),
withSingles(false) {}
};
If the feature is of general interest I can open a pull request for a proper review.