diff --git a/MMVII/include/MMVII_DeclareAllCmd.h b/MMVII/include/MMVII_DeclareAllCmd.h index 908741052..837c9c996 100755 --- a/MMVII/include/MMVII_DeclareAllCmd.h +++ b/MMVII/include/MMVII_DeclareAllCmd.h @@ -114,6 +114,8 @@ extern cSpecMMVII_Appli TheSpec_CERN_ImportClino; extern cSpecMMVII_Appli TheSpec_MMV2_MesIm_2_MMV1; extern cSpecMMVII_Appli TheSpec_MergeMesImGCP; + +extern cSpecMMVII_Appli TheSpec_ExifData; }; #endif // _MMVII_DeclareAllCmd_H_ diff --git a/MMVII/src/Appli/cSpecMMVII_Appli.cpp b/MMVII/src/Appli/cSpecMMVII_Appli.cpp index 85b630a4a..b19a4b933 100755 --- a/MMVII/src/Appli/cSpecMMVII_Appli.cpp +++ b/MMVII/src/Appli/cSpecMMVII_Appli.cpp @@ -260,6 +260,8 @@ std::vector & cSpecMMVII_Appli::InternVecAll() TheVecAll.push_back(&TheSpec_MMV2_MesIm_2_MMV1); TheVecAll.push_back(&TheSpec_MergeMesImGCP); + + TheVecAll.push_back(&TheSpec_ExifData); std::sort(TheVecAll.begin(),TheVecAll.end(),CmpCmd); } diff --git a/MMVII/src/ImagesBase/AppliExifData.cpp b/MMVII/src/ImagesBase/AppliExifData.cpp new file mode 100755 index 000000000..91217f66c --- /dev/null +++ b/MMVII/src/ImagesBase/AppliExifData.cpp @@ -0,0 +1,137 @@ +#include "MMVII_ExifData.h" +#include "cMMVII_Appli.h" + +namespace MMVII +{ + +class cAppli_ExifData : public cMMVII_Appli +{ +public : + cAppli_ExifData(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec,bool isBasic); + int Exe() override; + cCollecSpecArg2007 & ArgObl(cCollecSpecArg2007 & anArgObl) override ; + cCollecSpecArg2007 & ArgOpt(cCollecSpecArg2007 & anArgOpt) override ; + +private : + std::string mNameIn; ///< Input image name + int mDisp; +}; + +cCollecSpecArg2007 & cAppli_ExifData::ArgObl(cCollecSpecArg2007 & anArgObl) +{ + return + anArgObl + << Arg2007(mNameIn,"Name of input file",{{eTA2007::MPatFile,"0"},eTA2007::FileImage}) + ; +} + +cCollecSpecArg2007 & cAppli_ExifData::ArgOpt(cCollecSpecArg2007 & anArgOpt) +{ + return + anArgOpt + << AOpt2007(mDisp,"Disp","0->All known tags , 1->Main tags, 2->Raw strings",{eTA2007::HDV,{eTA2007::Range,"[0,2]"}}) + ; +} + + + +template +std::ostream& operator<<(std::ostream& os, std::optional const& opt) +{ + return opt ? os << opt.value() : os << ""; +} + + +int cAppli_ExifData::Exe() +{ + for (const auto & aName : VectMainSet(0)) + { + std::cout << "####### " << aName <<":" << std::endl; + if (mDisp == 2) { + auto anExifList = cExifData::StringListFromFile(aName); + for (const auto &s : anExifList) + std::cout << s << std::endl; + } + + if (mDisp == 0 || mDisp == 1) { + auto anExif = cExifData::CreateFromFile(aName); + std::cout << std::setprecision(17); + +#define DISP_EXIF(key) std::cout << #key << ": " << anExif.m##key << std::endl; + + DISP_EXIF(ExifVersion); + + DISP_EXIF(PixelXDimension); + DISP_EXIF(PixelYDimension); + + DISP_EXIF(FocalLength_mm); + DISP_EXIF(FocalLengthIn35mmFilm_mm); + DISP_EXIF(FNumber); + DISP_EXIF(ExposureTime_s); + DISP_EXIF(Orientation); + DISP_EXIF(Make); + DISP_EXIF(Model); + DISP_EXIF(LensMake); + DISP_EXIF(LensModel); + if (mDisp == 0) { + DISP_EXIF(XResolution); + DISP_EXIF(YResolution); + DISP_EXIF(ResolutionUnit); + DISP_EXIF(FocalPlaneXResolution); + DISP_EXIF(FocalPlaneYResolution); + DISP_EXIF(FocalPlaneResolutionUnit); + + DISP_EXIF(DateTime); + DISP_EXIF(SubSecTime); + DISP_EXIF(DateTimeOriginal); + DISP_EXIF(SubSecTimeOriginal); + DISP_EXIF(DateTimeDigitized); + DISP_EXIF(SubSecTimeDigitized); + + DISP_EXIF(DateTimeNumber_s); + DISP_EXIF(DateTimeOriginalNumber_s); + DISP_EXIF(DateTimeDigitizedNumber_s); + + DISP_EXIF(GPSLongitude_deg); + DISP_EXIF(GPSLatitude_deg); + DISP_EXIF(GPSAltitude_m); + + DISP_EXIF(GPSDateStamp); + DISP_EXIF(GPSTimeStamp); + DISP_EXIF(GPSTimeUTC_s); + DISP_EXIF(GPSTimeUTC_ns); + + DISP_EXIF(ExifVersion); + } + } + std::cout << std::endl; + } + return EXIT_SUCCESS; +} + + +cAppli_ExifData:: cAppli_ExifData(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec,bool isBasic) : + cMMVII_Appli (aVArgs,aSpec), + mDisp(0) +{ +} + + +tMMVII_UnikPApli Alloc_ExifData(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec) +{ + return tMMVII_UnikPApli(new cAppli_ExifData(aVArgs,aSpec,true)); +} + +cSpecMMVII_Appli TheSpec_ExifData + ( + "ExifData", + Alloc_ExifData, + "Display Exif metadata from image file", + {eApF::ImProc}, + {eApDT::Image}, + {eApDT::Console}, + __FILE__ + ); + + +} // namespace MMVII