1 /*****************************************************************************
5 ** Purpose: Display information about an image file
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: April 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 * ifinfo.c Display info on sdf files
34 enum { O_LABELS, O_STATS, O_NO_STATS, O_NO_LABELS, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
36 static struct option my_options[] =
38 {"labels", 0, 0, O_LABELS},
39 {"no-labels", 0, 0, O_NO_LABELS},
40 {"stats", 0, 0, O_STATS},
41 {"no-stats", 0, 0, O_NO_STATS},
42 {"debug", 0, 0, O_DEBUG},
43 {"verbose", 0, 0, O_VERBOSE},
44 {"help", 0, 0, O_HELP},
45 {"version", 0, 0, O_VERSION},
49 static const char* g_szIdStr = "$Id$";
53 ifinfo_usage (const char *program)
55 std::cout << "usage: " << fileBasename(program) << " image-filename [OPTIONS]\n";
56 std::cout << "Imagefile information\n";
57 std::cout << std::endl;
58 std::cout << " infile Name of input IF file\n";
59 std::cout << " --display Display image\n";
60 std::cout << " --labels Print image labels (default)\n";
61 std::cout << " --no-labels Do not print image labels\n";
62 std::cout << " --stats Print image statistics (default)\n";
63 std::cout << " --no-stats Do not print image statistics\n";
64 std::cout << " --debug Debug mode\n";
65 std::cout << " --verbose Verbose mode\n";
66 std::cout << " --version Print version\n";
67 std::cout << " --help Print this help message\n";
71 ifinfo_main (int argc, char *const argv[])
82 int c = getopt_long (argc, argv, "", my_options, NULL);
109 std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
111 std::cout << "Unknown version number\n";
116 ifinfo_usage(argv[0]);
119 ifinfo_usage(argv[0]);
124 if (optind + 1 != argc) {
125 ifinfo_usage (argv[0]);
129 in_file = argv[optind];
131 im = new ImageFile ();
132 if (! im->fileRead (in_file)) {
133 sys_error (ERR_WARNING, "Unable to read file %s", in_file.c_str());
138 im->printLabels (std::cout);
141 std::cout << "Size: (" << im->nx() << "," << im->ny() << ")\n";
142 std::cout << "Data type: ";
143 if (im->dataType() == Array2dFile::DATA_TYPE_COMPLEX)
144 std::cout << "Complex\n";
146 std::cout << "Real\n";
148 im->printStatistics (std::cout);
156 main (int argc, char *const argv[])
161 retval = ifinfo_main(argc, argv);
162 } catch (exception e) {
163 std::cerr << "Exception: " << e.what() << std::endl;
165 std::cerr << "Unknown exception\n";