00001 #include <iostream> 00002 00003 #include <archon/util/exception.H> 00004 #include <archon/util/image.H> 00005 00006 using namespace std; 00007 using namespace Archon::Utilities; 00008 00009 int main(int argc, const char *argv[]) 00010 { 00011 set_unexpected(Exception::terminal<exceptionCatchInfo>); 00012 set_terminate (Exception::terminal<exceptionCatchInfo>); 00013 00014 cout << "These image formats are supported:"; 00015 const Image::Context *imageContext = Image::Context::get(); 00016 for(size_t i = 0; i<imageContext->getNumberOfFormats(); ++i) 00017 cout << " " << imageContext->getFormat(i)->getSpecifier(); 00018 cout << endl; 00019 00020 if(argc < 3 || 6 < argc) 00021 { 00022 cerr << "Synopsis: " + string(argv[0]) + " IN-FILE OUT-FILE [ OUT-FORMAT ] [ IN-FORMAT ] [ NEW-COMMENT ]" << endl; 00023 exit(1); 00024 } 00025 00026 string inFile = argv[1]; 00027 string outFile = argv[2]; 00028 00029 string inFormat = argc < 5 ? "" : argv[4]; 00030 string outFormat = argc < 4 ? "" : argv[3]; 00031 00032 Image i(inFile, inFormat); 00033 00034 cout << "Loaded" << endl; 00035 00036 string oldComment = i.getComment(); 00037 if(5 < argc) i.setComment(argv[5]); 00038 00039 i.save(outFile, outFormat); 00040 00041 cout << "Saved" << endl; 00042 00043 if(oldComment.empty()) cout << "Image had no commment." << endl; 00044 else cout << "Image had the following comment:" << endl << "-->" << oldComment << "<--" << endl; 00045 00046 return 0; 00047 }