#include #include #include #include #include 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 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 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 I(fmask.str()); I.save(fmask.str() + ".ppm"); } }