bfdd8910
David Mayerich
initial commit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <iostream>
#include <vector>
#include <stim/parser/arguments.h>
#include <stim/parser/filename.h>
#include <stim/image/image.h>
int main(int argc, char* argv[]) {
stim::arglist args;
args.parse(argc, argv);
if (args.nargs() == 0) {
std::cout << "Specify a file or file list to convert images to Netpbm." << std::endl;
exit(0);
}
stim::filename fmask(args.arg(0));
stim::filepath fpath("."); //default to the current file path
if (args.nargs() == 2) fpath = args.arg(1); //if a destination path is specified, save there
if (fmask.wildcards()) { //if the given file name contains wild cards
std::vector<stim::filename> flist; //declare an STL vector
flist = fmask.get_list(); //get the corresponding file list
for (size_t i = 0; i < flist.size(); i++) { //for each file in the list
stim::image<unsigned char> I(flist[i].str()); //load the corresponding image
std::string outname = fpath.str() + flist[i].prefix() + ".ppm";
std::cout << "Saving " << outname << std::endl;
I.save_netpbm(outname); //save the file as a PPM
}
}
else {
stim::image<unsigned char> I(fmask.str());
I.save(fmask.str() + ".ppm");
}
}
|