]> Creatis software - clitk.git/blob - tools/clitkImageInfo.cxx
XVI IO
[clitk.git] / tools / clitkImageInfo.cxx
1 /*=========================================================================
2                                                                                 
3 Program:   clitk
4 Language:  C++
5
6 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
7 l'Image). All rights reserved. See Doc/License.txt or
8 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
9                                                                                 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE.  See the above copyright notices for more information.
13                                                                              
14 =========================================================================*/
15
16 /**
17    =================================================
18    * @file   clitkImageInfo.cxx
19    * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
20    * @date   02 Jul 2006
21    =================================================*/
22
23 // itk include
24 #include "itkImageIOBase.h"
25
26 // clitk include
27 #include "clitkImageInfo_ggo.h"
28 #include "clitkIO.h"
29 #include "clitkImageCommon.h"
30
31 //====================================================================
32 int main(int argc, char * argv[]) {
33
34   // init command line
35   GGO(clitkImageInfo, args_info);
36   CLITK_INIT;
37
38   // check arg
39   if (args_info.inputs_num == 0) return 0;
40
41   // read Header 
42   for(unsigned int i=0; i<args_info.inputs_num; i++) {
43     itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.inputs[i]);
44     if (header) {
45       if (args_info.name_flag) std::cout << "[" << args_info.inputs[i] << "]\t ";
46       if (args_info.long_given) {
47         //      std::cout << std::endl;
48         clitk::printImageHeader(header, std::cout, args_info.long_arg);
49       }
50       else {
51         if (args_info.verbose_flag) clitk::printImageHeader(header, std::cout, 1);
52         else {
53           clitk::printImageHeader(header, std::cout, 0);
54           std::cout << std::endl;
55         }
56       }
57     }  // heade null ; non fatal error
58       else {
59         std::cerr << "*** Warning : I could not read '" << args_info.inputs[i] << "' ***" << std::endl;
60       }
61   }
62
63   // this is the end my friend  
64   return 0;
65 }
66 //====================================================================